Ticket #685: 685_allow_empty.diff

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

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

  • django/views/generic/date_based.py

    diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py
    index e6a75e6..a745559 100644
    a b from django.http import Http404, HttpResponse  
    99
    1010def archive_index(request, queryset, date_field, num_latest=15,
    1111        template_name=None, template_loader=loader,
    12         extra_context=None, allow_empty=False, context_processors=None,
     12        extra_context=None, allow_empty=True, context_processors=None,
    1313        mimetype=None, allow_future=False, template_object_name='latest'):
    1414    """
    1515    Generic top-level archive of date-based objects.
  • django/views/generic/list_detail.py

    diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py
    index b72173b..617a644 100644
    a b from django.core.paginator import ObjectPaginator, InvalidPage  
    55from django.core.exceptions import ObjectDoesNotExist
    66
    77def object_list(request, queryset, paginate_by=None, page=None,
    8         allow_empty=False, template_name=None, template_loader=loader,
     8        allow_empty=True, template_name=None, template_loader=loader,
    99        extra_context=None, context_processors=None, template_object_name='object',
    1010        mimetype=None):
    1111    """
  • docs/generic_views.txt

    diff --git a/docs/generic_views.txt b/docs/generic_views.txt
    index 08ff01c..1718789 100644
    a b a date in the *future* are not included unless you set ``allow_future`` to  
    188188    * ``allow_empty``: A boolean specifying whether to display the page if no
    189189      objects are available. If this is ``False`` and no objects are available,
    190190      the view will raise a 404 instead of displaying an empty page. By
    191       default, this is ``False``.
     191      default, this is ``True``.
    192192
    193193    * ``context_processors``: A list of template-context processors to apply to
    194194      the view's template. See the `RequestContext docs`_.
    A page representing a list of objects.  
    718718    * ``allow_empty``: A boolean specifying whether to display the page if no
    719719      objects are available. If this is ``False`` and no objects are available,
    720720      the view will raise a 404 instead of displaying an empty page. By
    721       default, this is ``False``.
     721      default, this is ``True``.
    722722
    723723    * ``context_processors``: A list of template-context processors to apply to
    724724      the view's template. See the `RequestContext docs`_.
Back to Top