[Solved]-Django rest framework – PrimaryKeyRelatedField

18👍

From the Serializer Docs

The default ModelSerializer uses primary keys for relationships

If you don’t specify anything yourself PrimaryKeyRelatedField will be used under the hood, so your Variation 2 is the expected output.

Hopefully that helps.

Leave a comment