Skip to content

Instantly share code, notes, and snippets.

@olegkovalov
Created September 8, 2019 22:54
Show Gist options
  • Save olegkovalov/265e8c9e5c11197b8ea85c134ca431c3 to your computer and use it in GitHub Desktop.
Save olegkovalov/265e8c9e5c11197b8ea85c134ca431c3 to your computer and use it in GitHub Desktop.
blog views
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