Open kaedroho opened 9 years ago
Where would urls.py, wsgi.py and manage.py be in this layout?
manage.py would be in the root alongsite fabfile.py, requirements.txt, etc
urls.py and wsgi.py would be in the project folder (/project_name/{urls,wsgi}.py
)
Just added an example to the above post to hopefully better illustrate the structure...
In this template, we put all the projects code in a subdirectory. This is a nice way to separate code from configuration. Making the project easier to browse (especially for people who are unfamilar with the project).
Theres a couple of issues though...
PYTHONPATH
needs to be set to a subdirectory of the project. Configuration managment systems and PaaS services need to know about this.I propose that we make two changes:
Make python run in the root directory (instead of the subdirectory)
PYTHONPATH
variable easy as the configuration management system would not need to be aware of the internal structure of the project. It will also make projects work nicely (without any extra configuration) on heroku/dokku/etcproject_name.
Move settings/urls/wsgi one level up
project_name/settings
).Example:
The biggest change this would mean for developers is the import paths for their apps would all change. For example, if you wanted to import the model
Foo
from the appapp1
, you'd have to dofrom my_project.app1.models import Foo
. I personally dont think this is a bad thing for the following reasons: