django rest framework create nested objects “Models” by POST

后端 未结 4 898
暖寄归人
暖寄归人 2020-12-23 12:29

I\'m trying POST a new a Nested Object, the problem is just create the \"top\" object (Playlist), but don\'t create the \"ChannelItem\"...

My Models:



        
4条回答
  •  抹茶落季
    2020-12-23 12:40

    Nested representations do not currently support read-write, and should instead be read-only.

    You should probably look into using a flat representation instead, using pk or hyperlinked relations.

    If you need the nested representation, you may want to consider having two separate endpoints - a flat writable endpoint, and a nested read-only endpoint.

提交回复
热议问题