More consistent examples

This commit is contained in:
Tom Christie 2013-02-26 19:54:04 +00:00
parent e7ca326555
commit 35331f5820

View File

@ -29,8 +29,8 @@ Example:
urlpatterns = patterns('blog.views', urlpatterns = patterns('blog.views',
url(r'^/$', 'api_root'), url(r'^/$', 'api_root'),
url(r'^comment/$', 'comment_root'), url(r'^comment/$', 'comment_list'),
url(r'^comment/(?P<pk>[0-9]+)/$', 'comment_instance') url(r'^comment/(?P<pk>[0-9]+)/$', 'comment_detail')
) )
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'html']) urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'html'])
@ -38,13 +38,12 @@ Example:
When using `format_suffix_patterns`, you must make sure to add the `'format'` keyword argument to the corresponding views. For example: When using `format_suffix_patterns`, you must make sure to add the `'format'` keyword argument to the corresponding views. For example:
@api_view(('GET', 'POST')) @api_view(('GET', 'POST'))
def api_root(request, format=None): def comment_list(request, format=None):
# do stuff... # do stuff...
Or with class based views: Or with class based views:
class CommentList(APIView): class CommentList(APIView):
def get(self, request, format=None): def get(self, request, format=None):
# do stuff... # do stuff...