MCPcopy
hub / github.com/django/django / get_dated_items

Method get_dated_items

django/views/generic/dates.py:528–574  ·  view source on GitHub ↗

Return (date_list, items, extra_context) for this request.

(self)

Source from the content-addressed store, hash-verified

526 """
527
528 def get_dated_items(self):
529 """Return (date_list, items, extra_context) for this request."""
530 year = self.get_year()
531 week = self.get_week()
532
533 date_field = self.get_date_field()
534 week_format = self.get_week_format()
535 week_choices = {"%W": "1", "%U": "0", "%V": "1"}
536 try:
537 week_start = week_choices[week_format]
538 except KeyError:
539 raise ValueError(
540 "Unknown week format %r. Choices are: %s"
541 % (
542 week_format,
543 ", ".join(sorted(week_choices)),
544 )
545 )
546 year_format = self.get_year_format()
547 if week_format == "%V" and year_format != "%G":
548 raise ValueError(
549 "ISO week directive '%s' is incompatible with the year "
550 "directive '%s'. Use the ISO year '%%G' instead."
551 % (
552 week_format,
553 year_format,
554 )
555 )
556 date = _date_from_string(year, year_format, week_start, "%w", week, week_format)
557 since = self._make_date_lookup_arg(date)
558 until = self._make_date_lookup_arg(self._get_next_week(date))
559 lookup_kwargs = {
560 "%s__gte" % date_field: since,
561 "%s__lt" % date_field: until,
562 }
563
564 qs = self.get_dated_queryset(**lookup_kwargs)
565
566 return (
567 None,
568 qs,
569 {
570 "week": date,
571 "next_week": self.get_next_week(date),
572 "previous_week": self.get_previous_week(date),
573 },
574 )
575
576
577class WeekArchiveView(MultipleObjectTemplateResponseMixin, BaseWeekArchiveView):

Callers

nothing calls this directly

Calls 12

_date_from_stringFunction · 0.85
get_yearMethod · 0.80
get_weekMethod · 0.80
get_date_fieldMethod · 0.80
get_week_formatMethod · 0.80
get_year_formatMethod · 0.80
_make_date_lookup_argMethod · 0.80
_get_next_weekMethod · 0.80
get_dated_querysetMethod · 0.80
get_next_weekMethod · 0.80
get_previous_weekMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected