Ticket #15363: get_query_set.patch

File get_query_set.patch, 4.4 KB (added by sorl, 14 years ago)
  • django/views/generic/dates.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    old mode 100644
    new mode 100755
    diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
    index dc1f6e3..50726f5 100644
    a b class BaseDateListView(MultipleObjectMixin, DateMixin, View):  
    186186        Get a queryset properly filtered according to `allow_future` and any
    187187        extra lookup kwargs.
    188188        """
    189         qs = self.get_queryset().filter(**lookup)
     189        qs = self.get_query_set().filter(**lookup)
    190190        date_field = self.get_date_field()
    191191        allow_future = self.get_allow_future()
    192192        allow_empty = self.get_allow_empty()
    class BaseDayArchiveView(YearMixin, MonthMixin, DayMixin, BaseDateListView):  
    404404        """
    405405        date_field = self.get_date_field()
    406406
    407         field = self.get_queryset().model._meta.get_field(date_field)
     407        field = self.get_query_set().model._meta.get_field(date_field)
    408408        lookup_kwargs = _date_lookup_for_field(field, date)
    409409
    410410        qs = self.get_dated_queryset(**lookup_kwargs)
    class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailV  
    460460                                 month, self.get_month_format(),
    461461                                 day, self.get_day_format())
    462462
    463         qs = self.get_queryset()
     463        qs = self.get_query_set()
    464464
    465465        if not self.get_allow_future() and date > datetime.date.today():
    466466            raise Http404(_(u"Future %(verbose_name_plural)s not available because %(class_name)s.allow_future is False.") % {
    def _get_next_prev_month(generic_view, naive_result, is_previous, use_first_day)  
    564564            lookup = {'%s__gte' % date_field: naive_result}
    565565            ordering = date_field
    566566
    567         qs = generic_view.get_queryset().filter(**lookup).order_by(ordering)
     567        qs = generic_view.get_query_set().filter(**lookup).order_by(ordering)
    568568
    569569        # Snag the first object from the queryset; if it doesn't exist that
    570570        # means there's no next/previous link available.
  • django/views/generic/detail.py

    diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
    index 0495db0..68c25e2 100644
    a b class SingleObjectMixin(object):  
    2626        # Use a custom queryset if provided; this is required for subclasses
    2727        # like DateDetailView
    2828        if queryset is None:
    29             queryset = self.get_queryset()
     29            queryset = self.get_query_set()
    3030
    3131        # Next, try looking up by primary key.
    3232        pk = self.kwargs.get('pk', None)
    class SingleObjectMixin(object):  
    5252                          {'verbose_name': queryset.model._meta.verbose_name})
    5353        return obj
    5454
    55     def get_queryset(self):
     55    def get_query_set(self):
    5656        """
    5757        Get the queryset to look an object up against. May not be called if
    5858        `get_object` is overridden.
  • django/views/generic/edit.py

    diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
    index ff87f7b..a5f037b 100644
    a b class ModelFormMixin(FormMixin, SingleObjectMixin):  
    8585            else:
    8686                # Try to get a queryset and extract the model class
    8787                # from that
    88                 model = self.get_queryset().model
     88                model = self.get_query_set().model
    8989            return model_forms.modelform_factory(model)
    9090
    9191    def get_form_kwargs(self):
  • django/views/generic/list.py

    diff --git a/django/views/generic/list.py b/django/views/generic/list.py
    index c50c055..95d83c8 100644
    a b class MultipleObjectMixin(object):  
    1616    context_object_name = None
    1717    paginator_class = Paginator
    1818
    19     def get_queryset(self):
     19    def get_query_set(self):
    2020        """
    2121        Get the list of items for this view. This must be an interable, and may
    2222        be a queryset (in which qs-specific behavior will be enabled).
    class MultipleObjectMixin(object):  
    113113
    114114class BaseListView(MultipleObjectMixin, View):
    115115    def get(self, request, *args, **kwargs):
    116         self.object_list = self.get_queryset()
     116        self.object_list = self.get_query_set()
    117117        allow_empty = self.get_allow_empty()
    118118        if not allow_empty and len(self.object_list) == 0:
    119119            raise Http404(_(u"Empty list and '%(class_name)s.allow_empty' is False.")
Back to Top