Skip to content

Instantly share code, notes, and snippets.

@esirK
Created November 20, 2018 12:02
Show Gist options
  • Select an option

  • Save esirK/1bdc94f90d7b629fab52d878155ff42d to your computer and use it in GitHub Desktop.

Select an option

Save esirK/1bdc94f90d7b629fab52d878155ff42d to your computer and use it in GitHub Desktop.
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