aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/5-relationships-and-hyperlinked-apis.md
diff options
context:
space:
mode:
authorPavel Savchenko2012-10-31 00:37:30 +0200
committerPavel Savchenko2012-10-31 00:37:30 +0200
commita3ace366db4c664c88bf76b10b40b4c576c130dd (patch)
treee09ee831ac534f2b410c4ea9615cc67a219f558c /docs/tutorial/5-relationships-and-hyperlinked-apis.md
parent166025c0fcd0cfdcac1dbcbf31dbfc1d43f666b4 (diff)
downloaddjango-rest-framework-a3ace366db4c664c88bf76b10b40b4c576c130dd.tar.bz2
using 'pk' in fields throws KeyError
add missing imports Browsable API seems to be working fine with FBV's (2.0.0) removing snippets from the URI doesn't make sense remain consistent in using SnippetDetail
Diffstat (limited to 'docs/tutorial/5-relationships-and-hyperlinked-apis.md')
-rw-r--r--docs/tutorial/5-relationships-and-hyperlinked-apis.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md
index 1f663745..a666ad82 100644
--- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md
+++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md
@@ -29,7 +29,10 @@ Unlike all our other API endpoints, we don't want to use JSON, but instead just
The other thing we need to consider when creating the code highlight view is that there's no existing concreate generic view that we can use. We're not returning an object instance, but instead a property of an object instance.
-Instead of using a concrete generic view, we'll use the base class for representing instances, and create our own `.get()` method.
+Instead of using a concrete generic view, we'll use the base class for representing instances, and create our own `.get()` method. In your snippets.views add:
+
+ from rest_framework import renderers
+ from rest_framework.response import Response
class SnippetHighlight(generics.SingleObjectAPIView):
model = Snippet
@@ -111,7 +114,7 @@ After adding all those names into our URLconf, our final `'urls.py'` file should
views.SnippetList.as_view(),
name='snippet-list'),
url(r'^snippets/(?P<pk>[0-9]+)/$',
- views.SnippetInstance.as_view(),
+ views.SnippetDetail.as_view(),
name='snippet-detail'),
url(r'^snippets/(?P<pk>[0-9]+)/highlight/$'
views.SnippetHighlight.as_view(),