Used QuerySet.datetimes in date-based generic views.
This commit is contained in:
parent
9c0859ff7c
commit
0d0de288a5
|
@ -379,15 +379,18 @@ class BaseDateListView(MultipleObjectMixin, DateMixin, View):
|
||||||
|
|
||||||
def get_date_list(self, queryset, date_type=None, ordering='ASC'):
|
def get_date_list(self, queryset, date_type=None, ordering='ASC'):
|
||||||
"""
|
"""
|
||||||
Get a date list by calling `queryset.dates()`, checking along the way
|
Get a date list by calling `queryset.dates/datetimes()`, checking
|
||||||
for empty lists that aren't allowed.
|
along the way for empty lists that aren't allowed.
|
||||||
"""
|
"""
|
||||||
date_field = self.get_date_field()
|
date_field = self.get_date_field()
|
||||||
allow_empty = self.get_allow_empty()
|
allow_empty = self.get_allow_empty()
|
||||||
if date_type is None:
|
if date_type is None:
|
||||||
date_type = self.get_date_list_period()
|
date_type = self.get_date_list_period()
|
||||||
|
|
||||||
date_list = queryset.dates(date_field, date_type, ordering)
|
if self.uses_datetime_field:
|
||||||
|
date_list = queryset.datetimes(date_field, date_type, ordering)
|
||||||
|
else:
|
||||||
|
date_list = queryset.dates(date_field, date_type, ordering)
|
||||||
if date_list is not None and not date_list and not allow_empty:
|
if date_list is not None and not date_list and not allow_empty:
|
||||||
name = force_text(queryset.model._meta.verbose_name_plural)
|
name = force_text(queryset.model._meta.verbose_name_plural)
|
||||||
raise Http404(_("No %(verbose_name_plural)s available") %
|
raise Http404(_("No %(verbose_name_plural)s available") %
|
||||||
|
|
Loading…
Reference in New Issue