python - Django 1.8: How use Model from different application? -
my problem want create common-application (this can standard python module) e.g.:
model_1model_2model_3
and create application_1 , application_2 models common-application being used e.g.:
application_1model_1model_2model_4- app specific additional model
application_2model_1model_2model_3
really don't know how models.py , apps.py should like.. :/
is possible ?
ps. , if want write database_router split applications between 2 databases makes problem impossible solve ?
you can implement common models in common_application's models.py file abstract model, adding following model's class:
class meta: abstract = true then, in other applications can import common models so:
from common_application.models import model_1, model_2, model_3 and instantiate model classes derive abstract model class:
class model_1a(model_1): more details on model class inheritance can found here
Comments
Post a Comment