diff -rNu django-1/django/views/generic/date_based.py django-2/django/views/generic/date_based.py
old
|
new
|
|
22 | 22 | Latest N (defaults to 15) objects by date |
23 | 23 | """ |
24 | 24 | if extra_context is None: extra_context = {} |
| 25 | if callable(queryset): |
| 26 | queryset = queryset() |
25 | 27 | model = queryset.model |
26 | 28 | if not allow_future: |
27 | 29 | queryset = queryset.filter(**{'%s__lte' % date_field: datetime.datetime.now()}) |
… |
… |
|
66 | 68 | (Only available if make_object_list argument is True) |
67 | 69 | """ |
68 | 70 | if extra_context is None: extra_context = {} |
| 71 | if callable(queryset): |
| 72 | queryset = queryset() |
69 | 73 | model = queryset.model |
70 | 74 | now = datetime.datetime.now() |
71 | 75 | |
… |
… |
|
120 | 124 | except ValueError: |
121 | 125 | raise Http404 |
122 | 126 | |
| 127 | if callable(queryset): |
| 128 | queryset = queryset() |
123 | 129 | model = queryset.model |
124 | 130 | now = datetime.datetime.now() |
125 | 131 | |
… |
… |
|
185 | 191 | except ValueError: |
186 | 192 | raise Http404 |
187 | 193 | |
| 194 | if callable(queryset): |
| 195 | queryset = queryset() |
188 | 196 | model = queryset.model |
189 | 197 | now = datetime.datetime.now() |
190 | 198 | |
… |
… |
|
241 | 249 | except ValueError: |
242 | 250 | raise Http404 |
243 | 251 | |
| 252 | if callable(queryset): |
| 253 | queryset = queryset() |
244 | 254 | model = queryset.model |
245 | 255 | now = datetime.datetime.now() |
246 | 256 | |
… |
… |
|
311 | 321 | except ValueError: |
312 | 322 | raise Http404 |
313 | 323 | |
| 324 | if callable(queryset): |
| 325 | queryset = queryset() |
314 | 326 | model = queryset.model |
315 | 327 | now = datetime.datetime.now() |
316 | 328 | |
diff -rNu django-1/django/views/generic/list_detail.py django-2/django/views/generic/list_detail.py
old
|
new
|
|
43 | 43 | A list of the page numbers (1-indexed). |
44 | 44 | """ |
45 | 45 | if extra_context is None: extra_context = {} |
46 | | queryset = queryset._clone() |
| 46 | if callable(queryset): |
| 47 | queryset = queryset() |
| 48 | else: |
| 49 | queryset = queryset._clone() |
47 | 50 | if paginate_by: |
48 | 51 | paginator = Paginator(queryset, paginate_by, allow_empty_first_page=allow_empty) |
49 | 52 | if not page: |
… |
… |
|
115 | 118 | """ |
116 | 119 | if extra_context is None: extra_context = {} |
117 | 120 | model = queryset.model |
| 121 | if callable(queryset): |
| 122 | queryset = queryset() |
118 | 123 | if object_id: |
119 | 124 | queryset = queryset.filter(pk=object_id) |
120 | 125 | elif slug and slug_field: |
diff -rNu django-1/docs/ref/generic-views.txt django-2/docs/ref/generic-views.txt
old
|
new
|
|
57 | 57 | ``year``, etc. do above) or from the additional-information dictionary (as for |
58 | 58 | ``queryset``, ``date_field``, etc.). |
59 | 59 | |
60 | | Most generic views require the ``queryset`` key, which is a ``QuerySet`` |
61 | | instance; see :ref:`topics-db-queries` for more information about ``QuerySet`` |
62 | | objects. |
| 60 | Most generic views require the ``queryset`` key, which can be either a ``QuerySet`` |
| 61 | instance or a callable object which returns a ``QuerySet``; see |
| 62 | :ref:`topics-db-queries` for more information about ``QuerySet`` objects. |
63 | 63 | |
64 | 64 | Most views also take an optional ``extra_context`` dictionary that you can use |
65 | 65 | to pass any auxiliary information you wish to the view. The values in the |