简体   繁体   中英

Django Rest Framework - Automatically create new model B instance each and every time new model A instance is created

As said in the title. I want my django rest framework to create new model B object instance - with foreign key to model A, each and every time new model A object instance is created, so that they have foreign key relation. Currently i use ViewSets. Thanks for help in advance.

Just use post_save / pre_save signals.

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