When a Django Rest Framework (DRF) ModelChoiceField is used in a serializer, the value returned will be the primary key value of the selected object.

For example, if a serializer has a ModelChoiceField for a related model, and the user selects an object with a primary key of 1, the value returned will be 1.

This value can then be used to retrieve the selected object from the database or to update the related field in the parent object.

drf model choice field value return

原文地址: https://www.cveoy.top/t/topic/bsLW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录