Django using model of one app into other app's model

此生再无相见时 提交于 2020-01-05 07:39:11

问题


Salam and hi,

I am using django and breaking two parts of project in two apps. However there is a reference field of one table as foreign key of other in terms of db. So how can I use one app's model primary key as foreign key of another app's model? And if is not possible then should I just make single app of all such apps. I am actually thinking apps as different modules/components of project, may be I will be adding some apps in future.

thanks


回答1:


Either import the model from the other app, or refer to it by name in a string.



来源:https://stackoverflow.com/questions/8024927/django-using-model-of-one-app-into-other-apps-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!