问题
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