Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An example of how to use common model classes.
# import CommonModel, CommonSerializer, CommonViewSet
# from
class Note(CommonModel):
"""Note content, written by a user."""
text_body = models.TextField(default="")
class NoteSerializer(CommonSerializer):
"""Serialize requests for Text Content."""
# some permission_classes like (IsAuthenticated, )
# some authentication_classes like (SessionAuthentication, OAuth2Authentication,)
class Meta:
"""Meta class for TextContentSerializer."""
model = TextContent
fields = ['id', 'text_body'] + CommonSerializer.common_fields
class NoteViewSet(CommonViewSet):
"""Shows CRUD endpoints for Notes."""
queryset = Note.objects.all()
serializer_class = NoteSerializer
# some parser_classes like parsers.JSONParser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment