I am using Django REST Framework to create an API for my web app. I have a class \'Comment\', that has depth=2
set in the Meta
class. This works gr
I believe the proper way to define a serializer field that refers to a foreign key relationship is through something like serializers.PrimaryKeyRelatedField
. I don't believe that model serializers automatically use this field class without defining it explicitly in the serializer class.
http://www.django-rest-framework.org/api-guide/relations/#primarykeyrelatedfield
I would imagine that a PrimaryKeyRelatedField
serializer would correctly handle JSON data submissions like the one you used in your example.