Created
November 20, 2018 12:02
-
-
Save esirK/1bdc94f90d7b629fab52d878155ff42d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArticleView(CreateAPIView, ListAPIView): | |
| queryset = Article.objects.all() | |
| serializer_class = ArticleSerializer | |
| def perform_create(self, serializer): | |
| author = get_object_or_404(Author, id=self.request.data.get('author_id')) | |
| return serializer.save(author=author) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment