Ticket #24263: 24263.diff

File 24263.diff, 1.5 KB (added by EugeneM, 10 years ago)

Patch with test

  • django/views/generic/dates.py

    diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
    index b80b7ff..4b48439 100644
    a b class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV  
    644644                                 day, self.get_day_format())
    645645
    646646        # Use a custom queryset if provided
    647         qs = queryset or self.get_queryset()
     647        qs = self.get_queryset() if queryset is None else queryset
    648648
    649649        if not self.get_allow_future() and date > datetime.date.today():
    650650            raise Http404(_("Future %(verbose_name_plural)s not available because %(class_name)s.allow_future is False.") % {
  • tests/generic_views/test_dates.py

    diff --git a/tests/generic_views/test_dates.py b/tests/generic_views/test_dates.py
    index 07cb13a..a090876 100644
    a b class DateDetailViewTests(TestCase):  
    602602            '/dates/books/get_object_custom_queryset/2008/oct/01/1/')
    603603        self.assertEqual(res.status_code, 404)
    604604
     605    def test_get_object_custom_queryset_numqueries(self):
     606        # Regression test for #24263
     607        with self.assertNumQueries(1):
     608            self.client.get(
     609            '/dates/books/get_object_custom_queryset/2006/may/01/2/')
     610
    605611    def test_datetime_date_detail(self):
    606612        bs = BookSigning.objects.create(event_date=datetime.datetime(2008, 4, 2, 12, 0))
    607613        res = self.client.get('/dates/booksignings/2008/apr/2/%d/' % bs.pk)
Back to Top