thinkster-django-angular-tutorial
thinkster-django-angular-tutorial copied to clipboard
Chapter 6: PostViewSet.perform_create creates an object twice
perform_create creates a Post object by invoking save on the serializer and passing the author as an argument. Why would we need to call the parent perform_create (which calls update since instance is not None) ?
def perform_create(self, serializer):
instance = serializer.save(author=self.request.user)
return super(PostViewSet, self).perform_create(serializer)