Created
January 2, 2019 15:47
-
-
Save luiscberrocal/654512ed6e078240e92f7762fe5be9c3 to your computer and use it in GitHub Desktop.
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 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