From ae0ed721cd744c00a7e63ec96f9f1f09adc9b9b9 Mon Sep 17 00:00:00 2001 From: Chris Frisina Date: Mon, 27 Aug 2018 00:33:05 -0400 Subject: [PATCH] Removing (potential erroneous) confusing dot "`.`method()" While it would be invoked with a dot, I believe the the method should be referenced by its name --- tutorial/4-authentication-and-permissions/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorial/4-authentication-and-permissions/index.html b/tutorial/4-authentication-and-permissions/index.html index 59aada293..565345fad 100644 --- a/tutorial/4-authentication-and-permissions/index.html +++ b/tutorial/4-authentication-and-permissions/index.html @@ -520,7 +520,7 @@ url(r'^users/(?P<pk>[0-9]+)/$', views.UserDetail.as_view()),

Associating Snippets with Users

Right now, if we created a code snippet, there'd be no way of associating the user that created the snippet, with the snippet instance. The user isn't sent as part of the serialized representation, but is instead a property of the incoming request.

-

The way we deal with that is by overriding a .perform_create() method on our snippet views, that allows us to modify how the instance save is managed, and handle any information that is implicit in the incoming request or requested URL.

+

The way we deal with that is by overriding a perform_create() method on our snippet views, that allows us to modify how the instance save is managed, and handle any information that is implicit in the incoming request or requested URL.

On the SnippetList view class, add the following method:

def perform_create(self, serializer):
     serializer.save(owner=self.request.user)
@@ -660,4 +660,4 @@ class IsOwnerOrReadOnly(permissions.BasePermission):
   
 
 
-
\ No newline at end of file
+