Ticket #5085: set-default-value-of-slug_field-to-slug.diff

File set-default-value-of-slug_field-to-slug.diff, 4.3 KB (added by Trevor Caira <trevor@…>, 17 years ago)

Add default values to generic view parameters and update documentation

  • django/views/generic/date_based.py

     
    286286
    287287def object_detail(request, year, month, day, queryset, date_field,
    288288        month_format='%b', day_format='%d', object_id=None, slug=None,
    289         slug_field=None, template_name=None, template_name_field=None,
     289        slug_field='slug', template_name=None, template_name_field=None,
    290290        template_loader=loader, extra_context=None, context_processors=None,
    291291        template_object_name='object', mimetype=None, allow_future=False):
    292292    """
  • django/views/generic/list_detail.py

     
    8787    return HttpResponse(t.render(c), mimetype=mimetype)
    8888
    8989def object_detail(request, queryset, object_id=None, slug=None,
    90         slug_field=None, template_name=None, template_name_field=None,
     90        slug_field='slug', template_name=None, template_name_field=None,
    9191        template_loader=loader, extra_context=None,
    9292        context_processors=None, template_object_name='object',
    9393        mimetype=None):
  • django/views/generic/create_update.py

     
    7171    return HttpResponse(t.render(c))
    7272
    7373def update_object(request, model, object_id=None, slug=None,
    74         slug_field=None, template_name=None, template_loader=loader,
     74        slug_field='slug', template_name=None, template_loader=loader,
    7575        extra_context=None, post_save_redirect=None,
    7676        login_required=False, follow=None, context_processors=None,
    7777        template_object_name='object'):
     
    146146    return response
    147147
    148148def delete_object(request, model, post_delete_redirect,
    149         object_id=None, slug=None, slug_field=None, template_name=None,
     149        object_id=None, slug=None, slug_field='slug', template_name=None,
    150150        template_loader=loader, extra_context=None,
    151151        login_required=False, context_processors=None, template_object_name='object'):
    152152    """
  • docs/generic_views.txt

     
    4040    }
    4141
    4242    urlpatterns = patterns('django.views.generic.date_based',
    43        (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'object_detail', dict(info_dict, slug_field='slug')),
     43       (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'object_detail', info_dict),
    4444       (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$',               'archive_day',   info_dict),
    4545       (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$',                                'archive_month', info_dict),
    4646       (r'^(?P<year>\d{4})/$',                                                    'archive_year',  info_dict),
     
    603603
    604604      Otherwise, ``slug`` should be the slug of the given object, and
    605605      ``slug_field`` should be the name of the slug field in the ``QuerySet``'s
    606       model.
     606      model. By default, ``slug_field`` is ``'slug'``.
    607607
    608608**Optional arguments:**
    609609
     
    804804
    805805      Otherwise, ``slug`` should be the slug of the given object, and
    806806      ``slug_field`` should be the name of the slug field in the ``QuerySet``'s
    807       model.
     807      model. By default, ``slug_field`` is ``'slug'``.
    808808
    809809**Optional arguments:**
    810810
     
    948948
    949949      Otherwise, ``slug`` should be the slug of the given object, and
    950950      ``slug_field`` should be the name of the slug field in the ``QuerySet``'s
    951       model.
     951      model. By default, ``slug_field`` is ``'slug'``.
    952952
    953953**Optional arguments:**
    954954
     
    10331033
    10341034      Otherwise, ``slug`` should be the slug of the given object, and
    10351035      ``slug_field`` should be the name of the slug field in the ``QuerySet``'s
    1036       model.
     1036      model. By default, ``slug_field`` is ``'slug'``.
    10371037
    10381038    * ``post_delete_redirect``: A URL to which the view will redirect after
    10391039      deleting the object.
Back to Top