Verified Commit fa5101db authored by Micheal Gendy's avatar Micheal Gendy
Browse files

use GenericAPIView

parent 29c5f96b
......@@ -18,13 +18,12 @@ urlpatterns = [
API_VIEW = """from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import generics
from rest_framework.generics import GenericAPIView
from {{ app }}.serializers import {{ serializers|join:', ' }}
from {{ app }}.models import {{ models|join:', ' }}
{% for model in models %}
class {{ model }}APIView(generics.RetrieveUpdateDestroyAPIView):
queryset = {{ model }}.objects.all()
class {{ model }}APIView(GenericAPIView):
serializer_class = {{ model }}Serializer
def get(self, request, id, format=None):
try:
......@@ -54,7 +53,7 @@ class {{ model }}APIView(generics.RetrieveUpdateDestroyAPIView):
return Response(status=204)
class {{ model }}APIListView(generics.ListCreateAPIView):
class {{ model }}APIListView(GenericAPIView):
queryset = {{ model }}.objects.all()
serializer_class = {{ model }}Serializer
def get(self, request, format=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment