Ticket #16918: 16918.diff
File 16918.diff, 2.8 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/generic_views/views.py
177 177 class AuthorGetQuerySetFormView(generic.edit.ModelFormMixin): 178 178 def get_queryset(self): 179 179 return Author.objects.all() 180 181 class BookDetail16918(BookDetail): 182 # testing for #16918 183 def get_object(self, queryset=None): 184 return super(BookDetail16918,self).get_object(queryset=Book.objects.filter(pk=2)) 185 -
tests/regressiontests/generic_views/dates.py
412 412 def test_invalid_url(self): 413 413 self.assertRaises(AttributeError, self.client.get, "/dates/books/2008/oct/01/nopk/") 414 414 415 def test_16918(self): 416 # testing for #16918 417 res = self.client.get('/dates/books/16918/2006/may/01/2/') 418 self.assertEqual(res.status_code, 200) 419 self.assertEqual(res.context['object'], Book.objects.get(pk=2)) 420 self.assertEqual(res.context['book'], Book.objects.get(pk=2)) 421 self.assertTemplateUsed(res, 'generic_views/book_detail.html') 422 423 res = self.client.get('/dates/books/16918/2008/oct/01/1/') 424 self.assertEqual(res.status_code, 404) 425 -
tests/regressiontests/generic_views/urls.py
216 216 (r'^dates/books/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/byslug/(?P<slug>[\w-]+)/$', 217 217 views.BookDetail.as_view()), 218 218 219 # testing for #16918 220 (r'^dates/books/16918/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{1,2})/(?P<pk>\d+)/$', 221 views.BookDetail16918.as_view()), 222 219 223 # Useful for testing redirects 220 224 (r'^accounts/login/$', 'django.contrib.auth.views.login') 221 225 ) -
django/views/generic/dates.py
459 459 month, self.get_month_format(), 460 460 day, self.get_day_format()) 461 461 462 qs = self.get_queryset() 462 if queryset is None: 463 qs = self.get_queryset() 464 else: 465 qs = queryset 463 466 464 467 if not self.get_allow_future() and date > datetime.date.today(): 465 468 raise Http404(_(u"Future %(verbose_name_plural)s not available because %(class_name)s.allow_future is False.") % {