Code

Ticket #685: 685_allow_empty.diff

File 685_allow_empty.diff, 2.5 KB (added by mcroydon, 6 years ago)

Per jacob's comments, apply allow_empty to generic index views and update docs. Apply patch with -p1.

Line 
1diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py
2index e6a75e6..a745559 100644
3--- a/django/views/generic/date_based.py
4+++ b/django/views/generic/date_based.py
5@@ -9,7 +9,7 @@ from django.http import Http404, HttpResponse
6 
7 def archive_index(request, queryset, date_field, num_latest=15,
8         template_name=None, template_loader=loader,
9-        extra_context=None, allow_empty=False, context_processors=None,
10+        extra_context=None, allow_empty=True, context_processors=None,
11         mimetype=None, allow_future=False, template_object_name='latest'):
12     """
13     Generic top-level archive of date-based objects.
14diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py
15index b72173b..617a644 100644
16--- a/django/views/generic/list_detail.py
17+++ b/django/views/generic/list_detail.py
18@@ -5,7 +5,7 @@ from django.core.paginator import ObjectPaginator, InvalidPage
19 from django.core.exceptions import ObjectDoesNotExist
20 
21 def object_list(request, queryset, paginate_by=None, page=None,
22-        allow_empty=False, template_name=None, template_loader=loader,
23+        allow_empty=True, template_name=None, template_loader=loader,
24         extra_context=None, context_processors=None, template_object_name='object',
25         mimetype=None):
26     """
27diff --git a/docs/generic_views.txt b/docs/generic_views.txt
28index 08ff01c..1718789 100644
29--- a/docs/generic_views.txt
30+++ b/docs/generic_views.txt
31@@ -188,7 +188,7 @@ a date in the *future* are not included unless you set ``allow_future`` to
32     * ``allow_empty``: A boolean specifying whether to display the page if no
33       objects are available. If this is ``False`` and no objects are available,
34       the view will raise a 404 instead of displaying an empty page. By
35-      default, this is ``False``.
36+      default, this is ``True``.
37 
38     * ``context_processors``: A list of template-context processors to apply to
39       the view's template. See the `RequestContext docs`_.
40@@ -718,7 +718,7 @@ A page representing a list of objects.
41     * ``allow_empty``: A boolean specifying whether to display the page if no
42       objects are available. If this is ``False`` and no objects are available,
43       the view will raise a 404 instead of displaying an empty page. By
44-      default, this is ``False``.
45+      default, this is ``True``.
46 
47     * ``context_processors``: A list of template-context processors to apply to
48       the view's template. See the `RequestContext docs`_.