Last active
April 6, 2017 06:40
-
-
Save hassanabidpk/eba5b8f604084e203c241e30956fad64 to your computer and use it in GitHub Desktop.
views.py for Medium blog post
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 .serializers import RestaurantSerializer | |
from rest_framework import status, permissions | |
from rest_framework import mixins, generics | |
class RestaurantList(mixins.ListModelMixin, | |
mixins.CreateModelMixin, | |
generics.GenericAPIView): | |
""" | |
List all restaurant, or create a restaurant | |
""" | |
#permission_classes = (permissions.IsAuthenticatedOrReadOnly,) | |
parser_classes = (JSONParser, MultiPartParser, FormParser,) | |
queryset = Restaurant.objects.all() | |
serializer_class = RestaurantSerializer | |
def get(self, request, *args, **kwargs): | |
return self.list(request, *args, **kwargs) | |
def post(self, request, *args, **kwargs): | |
return self.create(request, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment