You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 3, 2022. It is now read-only.
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.
The settings are deeply nested in a quite redundant-looking path.
I propose that we make two changes:
Make python run in the root directory (instead of the subdirectory)
The subdirectory will still exist and contain all the apps for the project
This would make setting the 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/etc
This is how python packages are structured
This would require imports between the apps in the project be prefixed with project_name.
Move settings/urls/wsgi one level up
We currently have a subfolder inside the code directory named after the project for settings, urls.py, wsgi.py, etc.
I think we should move all of these files into the main code directory (so settings is found at project_name/settings).
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 app app1, you'd have to do from my_project.app1.models import Foo. I personally dont think this is a bad thing for the following reasons:
Importing between apps is uncommon
Namespacing apps like this can be good as apps often have generic names which may clash with installed packages
The text was updated successfully, but these errors were encountered:
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:The text was updated successfully, but these errors were encountered: