2👍
Try using different serializers for creation and representation.
class AdsCreateSerializer(serializers.ModelSerializer):
class Meta:
model = Ads
fields = "__all__"
class AdsSerializer(serializers.ModelSerializer):
display = DisplaySerializer()
class Meta:
model = Ads
fields = "__all__"
-1👍
For display
field, AdsSerializer
expects the following structure;
"display": {"id": 91}
whereas you send this;
"display": 91
- [Answered ]-How can I fetch all SiteRelated objects for all sites in Mezzanine?
- [Answered ]-Migrating sqlite to mysql using Django – tables not created
- [Answered ]-Basics of testing signals in Django
- [Answered ]-Django URL logical OR misunderstood
Source:stackexchange.com