Sharing models between Django apps

Nicu Surdu picture Nicu Surdu · Nov 9, 2010 · Viewed 26.8k times · Source

I will be brief: to work in the spirit and idea of a Django app, it is ok for an app to import models from inside another app ? Say, a User statistics app will import models from a User app something like: from users.models import users

Answer

tarequeh picture tarequeh · Nov 9, 2010

The answer is yes. It's perfectly okay for one application inside your django project to import models from another application. The power of a django project lies in the apps and their interactions.

Also make sure that you have utility applications importing models from more generic applications and not the other way. So "userstatistics" app should import models from the "users" app but "users" app should not rely on the "userstatistics".

If your app is importing models from a 3rd party application (lets say django-piston), be sure to specify that in a requirements file.