Created
September 8, 2019 22:54
-
-
Save olegkovalov/265e8c9e5c11197b8ea85c134ca431c3 to your computer and use it in GitHub Desktop.
blog views
This file contains 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
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView | |
from django_blog.apps.blog.models import Post | |
from django_blog.apps.blog.rest_api.serializers.post import PostSerializer | |
class PostListCreateAPIView(ListCreateAPIView): | |
""" | |
API view to retrieve list of posts or create new | |
""" | |
serializer_class = PostSerializer | |
queryset = Post.objects.active() | |
class PostDetailsAPIView(RetrieveUpdateDestroyAPIView): | |
""" | |
API view to retrieve, update or delete post | |
""" | |
serializer_class = PostSerializer | |
queryset = Post.objects.active() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment