Skip to content
Advertisement

Getting an Assertion error in my django application(1.8.4)

from rest_framework import serializers
from .models import Stock


class StockSerializer(serializers.ModelSerializer):

    class Meta:

        model = Stock

        #field = ('ticker','volume')
        field = '__all__'

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.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement