MCPcopy
hub / github.com/django/django / _make_single_date_lookup

Method _make_single_date_lookup

django/views/generic/dates.py:282–299  ·  view source on GitHub ↗

Get the lookup kwargs for filtering on a single date. If the date field is a DateTimeField, we can't just filter on date_field=date because that doesn't take the time into account.

(self, date)

Source from the content-addressed store, hash-verified

280 return value
281
282 def _make_single_date_lookup(self, date):
283 """
284 Get the lookup kwargs for filtering on a single date.
285
286 If the date field is a DateTimeField, we can't just filter on
287 date_field=date because that doesn't take the time into account.
288 """
289 date_field = self.get_date_field()
290 if self.uses_datetime_field:
291 since = self._make_date_lookup_arg(date)
292 until = self._make_date_lookup_arg(date + datetime.timedelta(days=1))
293 return {
294 "%s__gte" % date_field: since,
295 "%s__lt" % date_field: until,
296 }
297 else:
298 # Skip self._make_date_lookup_arg, it's a no-op in this branch.
299 return {date_field: date}
300
301
302class BaseDateListView(MultipleObjectMixin, DateMixin, View):

Callers 2

_get_dated_itemsMethod · 0.80
get_objectMethod · 0.80

Calls 2

get_date_fieldMethod · 0.95
_make_date_lookup_argMethod · 0.95

Tested by

no test coverage detected