If I have two Django apps in the same project and both apps need to use the same table in the same database, how should I describe this table in two different models.py files?
If you declare a table in two separate apps within the django project you will have two separate tables. What you want to do is declare the model in the app where it makes the most sense and then import the model from the second app.
For example:
#app2.views
from app1.models import MyModel
Like this you will be referencing the same table from both locations and you won't have any weird situation in which you look for data and you don't find it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With