27đ
There shouldnât be any reason to have âproject level modelsâ (or âproject level viewsâ for that matter). You just need to split the functionality into separate apps.
Letâs say you are designing an intranet website for a school. You would have one app that deals with studentsâ accounts, and another app generating timetables, and yet another one for an internal message board, etc.. Every app defines its own models (there are no âproject level modelsâ), but apps can import each others models (so message board posts can have a ForeignKey field pointing at student from the âstudentsâ app).
See also James Bennettâs âwriting reusable Django applicationsâ presentation from DjangoCon 2008.
9đ
-
A model should only be defined once in a Django project
-
The model needs to exist in an app under the project
-
You can access other appâs models by importing them
-
If you need to âadd onâ to an existing model it can be inherited from (see: multi table inheritance). This is fairly simple but if youâre just starting out you may want to leave that for later.
- [Django]-Django: Filter a Queryset made of unions not working
- [Django]-Allowing RabbitMQ-Server Connections
- [Django]-Heroku, postgreSQL, django, comments, tastypie: No operator matches the given name and argument type(s). You might need to add explicit type casts
6đ
Django models can only reside in applications, not in project itself. By default manage.py inspectdb
outputs content of the models.py
file and itâs up to you to put it in the right place.
In your case it would be easier to put whole thing in one app and later split it in the places where it would make sense.
Iâm not sure whatâs the state with the current version, but before presence of models
module in package was indication that this is django application and can be put in INSTALLED_APPS
list.
- [Django]-Duplicate column name
- [Django]-How can I handle Exceptions raised by dango-social-auth?
- [Django]-How about having a SingletonModel in Django?