thinkster-django-angular-tutorial icon indicating copy to clipboard operation
thinkster-django-angular-tutorial copied to clipboard

Chapter 6: PostViewSet.perform_create creates an object twice

Open achraibi opened this issue 10 years ago • 0 comments

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)

achraibi avatar Sep 03 '15 17:09 achraibi