JavaScript
x
13
13
1
from rest_framework import serializers
2
from .models import Stock
3
4
5
class StockSerializer(serializers.ModelSerializer):
6
7
class Meta:
8
9
model = Stock
10
11
#field = ('ticker','volume')
12
field = '__all__'
13
I am getting an exception value on running application : ("Creating a ModelSerializer without either the 'fields' attribute or the 'exclude' attribute has been deprecated since 3.3.0, and is now disallowed. Add an explicit fields = '__all__' to the StockSerializer serializer.",)
Advertisement
Answer
As the error message says, the required attribute is fields
with an ‘s’, not field
.