I am trying to expose a nested serializer in my django (rest framework powered) API.
In my serializers.py , I have:
class SettingSerializer(serializers.ModelSerializer): class Meta: model = Setting fields = ('id', 'url', 'platform', 'state') class AppSerializer(serializers.HyperlinkedModelSerializer): settings = SettingSerializer(read_only=True) class Meta: model = Application fields = ('id', 'url', 'name', 'settings', 'created', 'updated')
but when I visit http://127.0.0.1:8000/api/v1/applications/ , the URL for opening apps, Django returns me an error: name 'SettingSerializer' is not defined .
This usually means that I would not import the class into the file I'm working on, but now the SettingSerializer is in the same file, so this should be something else.
Can you help me a little, what's wrong now?
Thanks in advance, Kostas
source share