Ticket #17508: t17508_1.diff
File t17508_1.diff, 2.5 KB (added by , 12 years ago) |
---|
-
django/views/generic/dates.py
diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py index 9ffaca4..1637670 100644
a b class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV 628 628 Detail view of a single object on a single date; this differs from the 629 629 standard DetailView by accepting a year/month/day in the URL. 630 630 """ 631 date_separate_unity = "daily" 632 631 633 def get_object(self, queryset=None): 632 634 """ 633 635 Get the object this request displays. 634 636 """ 635 year = self.get_year() 636 month = self.get_month() 637 day = self.get_day() 638 date = _date_from_string(year, self.get_year_format(), 639 month, self.get_month_format(), 640 day, self.get_day_format()) 637 date_field= self.get_date_field() 638 639 if self.date_separate_unity == "yearly": 640 date = _date_from_string(self.get_year(), self.get_year_format()) 641 get_until_date = self._get_next_year 642 elif self.date_separate_unity == "monthly": 643 date = _date_from_string(self.get_year(), self.get_year_format(), 644 self.get_month(), self.get_month_format()) 645 get_until_date = self._get_next_month 646 elif self.date_separate_unity == "daily": 647 date = _date_from_string(self.get_year(), self.get_year_format(), 648 self.get_month(), self.get_month_format(), 649 self.get_day(), self.get_day_format()) 650 get_until_date = self._get_next_day 651 else: 652 raise ValueError("Unknown date unit.") 641 653 642 654 # Use a custom queryset if provided 643 655 qs = queryset or self.get_queryset() … … class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV 651 663 # Filter down a queryset from self.queryset using the date from the 652 664 # URL. This'll get passed as the queryset to DetailView.get_object, 653 665 # which'll handle the 404 654 lookup_kwargs = self._make_single_date_lookup(date) 666 since = self._make_date_lookup_arg(date) 667 until = self._make_date_lookup_arg(get_until_date(date)) 668 669 lookup_kwargs = { 670 '%s__gte' % date_field: since, 671 '%s__lt' % date_field: until, 672 } 673 655 674 qs = qs.filter(**lookup_kwargs) 656 675 657 676 return super(BaseDetailView, self).get_object(queryset=qs)