We planned for two Django projects. Say, Project-1 contains Model A and B. and Other Project-2 contains Model C and D. But I am afraid if it possible or not as I am new in the Django World. Your suggestions would be highly appreciated.
Asked
Active
Viewed 226 times
-1
-
Sure you can, so long as they don't use the same database table names. However, it would be better to separate the projects into two databases since some of Django's core apps such as the migration framework uses a (nearly) hard-coded table name. – AKX Dec 21 '20 at 08:23
-
So long as each project used a unique name for the database `NAME` setting and your database supports multiple databases/schemas it should be fine – Iain Shelvington Dec 21 '20 at 08:30
1 Answers
0
You should add all models in both Django projects but the models that you want to not managed or ignored set the managed=False in Meta class of that model.
Project-1 models.py
*** another models
class ModelC(models.Model):
***
class Meta:
managed = False
class ModelD(models.Model):
***
class Meta:
managed = False
same this for the project2. see more information you need here.
Edited
Project-2 models.py
class ModelA(models.Model):
***
class Meta:
managed = False
class ModelB(models.Model):
***
class Meta:
managed = False
*** another models

Dad
- 377
- 2
- 8
-
This would mean neither project would be able to use Django's migrations, which is probably not what you'd want. – AKX Dec 21 '20 at 08:24
-
@AKX i just edited the answer, what i mean, that models A, B will be managed in Proejct-1 and models C and D could be managed in Project-2. – Dad Dec 21 '20 at 08:49
-
Thanks for your valuable response. I have another issue. What about if two project plan to apply individual custom User(AbstractUser) for example p1_user and p2_user in same database? – SirajBD Dec 21 '20 at 13:04