Last active
March 21, 2021 01:05
-
-
Save sankalpjonn/d379367568fbe2b6cdd76b96a095c21d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 import viewsets | |
| from rest_framework.permissions import IsAuthenticatedOrReadOnly | |
| class RecipeViewSet(viewsets.ModelViewSet): | |
| serializer_class = RecipeSerializer | |
| permission_classes = (IsAuthenticatedOrReadOnly,) | |
| def get_object(self): | |
| return get_object_or_404(Recipe, id=self.request.query_params.get("id")) | |
| def get_queryset(self): | |
| return Recipe.objects.all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment