James Pic
unread,Mar 12, 2016, 11:29:55 AM3/12/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-d...@googlegroups.com
Hi all,
There's a pattern I like to use in my projects which I'd like to
suggest for django startproject.
It looks like:
project_name/
setup.py
src/
myapp1/
myapp2/
project_name/
settings.py
urls.py
manage.py
wsgi.py
My settings.py here uses environment variables for everything to
override defaults.
Setup.py here allows:
- Adding an entry point,
- Installing all apps as packages,
- Installing test dependencies with extra_requires and pip install
project_name[test],
- Adding runtime dependencies.
For example, with that:
entry_points = {
'console_scripts': [
'project_name = project_name.manage:main',
],
},
And such a manage.py:
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project_name.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()
Installing the package will add the project_name command, allowing to
run `project_name migrate` for example from any directory.
I know it's too opinionated to add that to django, but I'd like to
open a discussion here and perhaps there's something we might find
worth changing in django's default project template.
Thanks for reading !