Created
November 20, 2018 11:26
-
-
Save esirK/ba8b21e74e21185f298d5eaebb3686a8 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(ListModelMixin, CreateModelMixin, GenericAPIView): | |
| 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) | |
| def get(self, request, *args, **kwargs): | |
| return self.list(request, *args, *kwargs) | |
| def post(self, request, *args, **kwargs): | |
| return self.create(request, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
o