Django

Code

Ticket #685: allow_empty=True.diff

File allow_empty=True.diff, 4.8 kB (added by Gary Wilson <gary.wilson@gmail.com>, 2 years ago)

default value of allow_empty changed to True for the generic views (archive_* except archive_week which already defaulted to True and object_list) with the documentation changes as well.

  • django/views/generic/date_based.py

    old new  
    77 
    88def archive_index(request, queryset, date_field, num_latest=15, 
    99        template_name=None, template_loader=loader, 
    10         extra_context=None, allow_empty=False, context_processors=None, 
     10        extra_context=None, allow_empty=True, context_processors=None, 
    1111        mimetype=None, allow_future=False): 
    1212    """ 
    1313    Generic top-level archive of date-based objects. 
     
    4747    return HttpResponse(t.render(c), mimetype=mimetype) 
    4848 
    4949def archive_year(request, year, queryset, date_field, template_name=None, 
    50         template_loader=loader, extra_context=None, allow_empty=False, 
     50        template_loader=loader, extra_context=None, allow_empty=True, 
    5151        context_processors=None, template_object_name='object', mimetype=None, 
    5252        make_object_list=False, allow_future=False): 
    5353    """ 
     
    9696 
    9797def archive_month(request, year, month, queryset, date_field, 
    9898        month_format='%b', template_name=None, template_loader=loader, 
    99         extra_context=None, allow_empty=False, context_processors=None, 
     99        extra_context=None, allow_empty=True, context_processors=None, 
    100100        template_object_name='object', mimetype=None, allow_future=False): 
    101101    """ 
    102102    Generic monthly archive view. 
     
    210210 
    211211def archive_day(request, year, month, day, queryset, date_field, 
    212212        month_format='%b', day_format='%d', template_name=None, 
    213         template_loader=loader, extra_context=None, allow_empty=False, 
     213        template_loader=loader, extra_context=None, allow_empty=True, 
    214214        context_processors=None, template_object_name='object', 
    215215        mimetype=None, allow_future=False): 
    216216    """ 
  • django/views/generic/list_detail.py

    old new  
    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

    old new  
    186186    * ``allow_empty``: A boolean specifying whether to display the page if no 
    187187      objects are available. If this is ``False`` and no objects are available, 
    188188      the view will raise a 404 instead of displaying an empty page. By 
    189       default, this is ``False``. 
     189      default, this is ``True``. 
    190190 
    191191    * ``context_processors``: A list of template-context processors to apply to 
    192192      the view's template. See the `RequestContext docs`_. 
     
    260260    * ``allow_empty``: A boolean specifying whether to display the page if no 
    261261      objects are available. If this is ``False`` and no objects are available, 
    262262      the view will raise a 404 instead of displaying an empty page. By 
    263       default, this is ``False``. 
     263      default, this is ``True``. 
    264264 
    265265    * ``context_processors``: A list of template-context processors to apply to 
    266266      the view's template. See the `RequestContext docs`_. 
     
    354354    * ``allow_empty``: A boolean specifying whether to display the page if no 
    355355      objects are available. If this is ``False`` and no objects are available, 
    356356      the view will raise a 404 instead of displaying an empty page. By 
    357       default, this is ``False``. 
     357      default, this is ``True``. 
    358358 
    359359    * ``context_processors``: A list of template-context processors to apply to 
    360360      the view's template. See the `RequestContext docs`_. 
     
    520520    * ``allow_empty``: A boolean specifying whether to display the page if no 
    521521      objects are available. If this is ``False`` and no objects are available, 
    522522      the view will raise a 404 instead of displaying an empty page. By 
    523       default, this is ``False``. 
     523      default, this is ``True``. 
    524524 
    525525    * ``context_processors``: A list of template-context processors to apply to 
    526526      the view's template. See the `RequestContext docs`_. 
     
    704704    * ``allow_empty``: A boolean specifying whether to display the page if no 
    705705      objects are available. If this is ``False`` and no objects are available, 
    706706      the view will raise a 404 instead of displaying an empty page. By 
    707       default, this is ``False``. 
     707      default, this is ``True``. 
    708708 
    709709    * ``context_processors``: A list of template-context processors to apply to 
    710710      the view's template. See the `RequestContext docs`_.