I have two Django apps that share a database and also a number of models. App 1 is used to administrate the data via the admin page. App 2 is used only to query the data and present the data. The apps are running on different servers.
My current solution is to run the exact same code in models.py on both apps. However, I have not run makemigration/migrate on app2. This solution works but makes me bothered by the fact that I have the same code in two models.py but only have one operational table in the database.
What is the correct way of dealing with this situation?
CodePudding user response:
I believe this is what you are looking for: https://docs.djangoproject.com/en/4.1/ref/models/options/#managed
In app2, you would add managed=False
to your various read-only models.
Something like:
class MyModel(models.Model):
class Meta:
managed = False
# db_table = 'the_table_name' add this if necessary only