2๐
โ
The urls come because you inherit HyperlinkedModelSerializer
.
class QuestionSerializer(serializers.HyperlinkedModelSerializer):
...
If you donโt want them, use a different base class โ perhaps just a ModelSerializer
.
๐คwim
2๐
I believe this will work.
class AnswerSerializer(serializers.ModelSerializer):
class Meta:
model = Answer
fields = ('answerid', 'text')
class QuestionSerializer(serializers.ModelSerializer):
answer = AnswerSerializer(source="answers)
class Meta:
model = Question
fields = ('question', 'answer', 'correct')
read_only_fields = ('answer',)
depth = 1
You may need to change the source
to correctly get the answers you need.
The serializers.HyperlinkedModelSerializer
will automatically insert the url field in your response.
๐คjarussi
- [Django]-How to run Django Web app on port 443 and 80 linux โ Ubuntu or Raspberry PI?
- [Django]-How insecure is this?
Source:stackexchange.com