Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save luiscberrocal/654512ed6e078240e92f7762fe5be9c3 to your computer and use it in GitHub Desktop.
Save luiscberrocal/654512ed6e078240e92f7762fe5be9c3 to your computer and use it in GitHub Desktop.
from rest_framework.generics import ListAPIView, RetrieveUpdateDestroyAPIView, CreateAPIView
from ..models import $MODEL_NAME$
class $MODEL_NAME$ListAPIView(ListAPIView):
serializer_class = $MODEL_NAME$Serializer
def get_queryset(self):
return $MODEL_NAME$.objects.all()
class $MODEL_NAME$DetailAPIView(RetrieveUpdateDestroyAPIView):
serializer_class = $MODEL_NAME$Serializer
queryset = $MODEL_NAME$.objects.all()
def get_object(self):
return super($MODEL_NAME$DetailAPIView, self).get_object()
class $MODEL_NAME$CreateAPIView(CreateAPIView):
serializer_class = $MODEL_NAME$Serializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment