diff options
Diffstat (limited to 'tutorial/6-viewsets-and-routers/index.html')
| -rw-r--r-- | tutorial/6-viewsets-and-routers/index.html | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/tutorial/6-viewsets-and-routers/index.html b/tutorial/6-viewsets-and-routers/index.html index 04071f9e..03839e8d 100644 --- a/tutorial/6-viewsets-and-routers/index.html +++ b/tutorial/6-viewsets-and-routers/index.html @@ -252,6 +252,10 @@                    </li>                    <li > +                    <a href="../../topics/project-management">Project management</a> +                  </li> +                   +                  <li >                      <a href="../../topics/rest-framework-2-announcement">2.0 Announcement</a>                    </li> @@ -423,8 +427,8 @@ class SnippetViewSet(viewsets.ModelViewSet):          snippet = self.get_object()          return Response(snippet.highlighted) -    def pre_save(self, obj): -        obj.owner = self.request.user +    def perform_create(self, serializer): +            serializer.save(owner=self.request.user)  </code></pre>  <p>This time we've used the <code>ModelViewSet</code> class in order to get the complete set of default read and write operations.</p>  <p>Notice that we've also used the <code>@detail_route</code> decorator to create a custom action, named <code>highlight</code>.  This decorator can be used to add any custom endpoints that don't fit into the standard <code>create</code>/<code>update</code>/<code>delete</code> style.</p> | 
