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
This commit is contained in:
Chris Frisina 2018-08-27 00:33:05 -04:00 committed by GitHub
parent 5c9eb645b1
commit ae0ed721cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -520,7 +520,7 @@ url(r'^users/(?P<pk>[0-9]+)/$', views.UserDetail.as_view()),
</code></pre>
<h2 id="associating-snippets-with-users"><a class="toclink" href="#associating-snippets-with-users">Associating Snippets with Users</a></h2>
<p>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.</p>
<p>The way we deal with that is by overriding a <code>.perform_create()</code> 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.</p>
<p>The way we deal with that is by overriding a <code>perform_create()</code> 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.</p>
<p>On the <code>SnippetList</code> view class, add the following method:</p>
<pre><code>def perform_create(self, serializer):
serializer.save(owner=self.request.user)
@ -660,4 +660,4 @@ class IsOwnerOrReadOnly(permissions.BasePermission):
</script>
</body>
</html>
</html>