from rest_framework.views import APIView
from meituan.models import Merchant
from django.http import Http404
from .serializers import MerchantSerializer
from rest_framework.response import Response
from rest_framework import status
from rest_framework import generics
class MerchantView(
generics.CreateAPIView,
generics.UpdateAPIView,
generics.DestroyAPIView,
generics.RetrieveAPIView
):
queryset = Merchant.objects.all()
serializer_class = MerchantSerializer
# lookup_field = 'name'
class MerthantListView(
generics.ListAPIView
):
queryset = Merchant.objects.all()
serializer_class = MerchantSerializer
- get_queryset(self):
- 通過重寫該方法實現復雜查詢后返回queryset對象。
return queryset
- get_object(self):
- perform_creat(self,serializer):
- perform_update(self,serializer):
- perform_destroy(self,serializer):