I want to use DjangoRestframework in django app but i get error when call it?
When call it , i give response me :
Exception Type: AssertionError
Exception Value: Class CrawlerSerializers missing "Meta" attribute
But i written Meta Class in serializer
class
Please help me
serializers.py file :
from rest_framework import serializers
from models import *
class CrawlerSerializers(serializers.ModelSerializer):
class meta:
model = Crawler
fields = ('source','category','template','url')
my View.py file :
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from models import *
from serializers import *
# Create your views here.
@api_view(['GET','POST'])
def crawler_list(request):
'''
list all task, or create a new task.
'''
if request.method == 'GET':
crawler = Crawler.objects.all()
serializer = CrawlerSerializers(crawler)
return Response(serializer.data)
elif request.method == "POST":
serializer = CrawlerSerializers(data=request.Data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data,status=status.HTTP_201_CREATED)
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
How to solve it?
meta
does not equalMeta
. Python is case-sensitive.