简体   繁体   中英

Return Create Object ID Django Rest Framework

I have a view that extends CreateAPIView. I'd like the ID of the created object included somewhere in the response. How can I accomplish this?

What does your serializer look like? Does it have the 'id' in the fields to be included?

http://www.django-rest-framework.org/api-guide/serializers/#specifying-which-fields-to-include

The serializer decides what the object returned looks like in the API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM