Created
August 14, 2018 17:09
-
-
Save anuj9196/2b836ac6186aab3596bf168e8604ff05 to your computer and use it in GitHub Desktop.
rest py
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
class ContactViewSet(viewsets.ModelViewSet): | |
""" | |
This viewset automatically provides `list`, `create`, `retrieve`, | |
`update` and `destroy` actions. | |
Additionally we also provide an extra `favourite`action | |
""" | |
serializer_class = ContactSerializer | |
permission_classes = (IsAuthenticated, AdminAuthenticationPermission,) | |
def get_queryset(self): | |
return Contact.objects.filter(user=self.request.user) | |
def perform_create(self, serializer): | |
serializer.save(user=self.request.user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment