Django startproject template enhancement proposal

136 views
Skip to first unread message

James Pic

unread,
Mar 12, 2016, 11:29:55 AM3/12/16
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 !

Florian Apolloner

unread,
Mar 12, 2016, 3:01:39 PM3/12/16
to Django developers (Contributions to Django itself)
On Saturday, March 12, 2016 at 5:29:55 PM UTC+1, is_null wrote:
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.

Imo it should stay as minimal as it is currently. Since we do allow you to specify --template to startproject, you can prepare a default project layout that suits you.

aRkadeFR

unread,
Mar 14, 2016, 3:36:20 AM3/14/16
to django-d...@googlegroups.com
FMPOV, the default template from Django influences:
- the use of settings in .py files over the environment variables;
- the use of manage.py over django-admin command;
- the merge of the "core application" and the project (settings/wsgi...) in one django app;

This is very personal and based on my experience while learning Django.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/95a6a70e-0499-456d-8dfe-326032710a64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Pic

unread,
Mar 14, 2016, 10:05:00 AM3/14/16
to django-d...@googlegroups.com
That sounds pretty fair, particularly since the new default settings
provide a great ootb experience.

Thanks for your feedback, keep up the great work !

Ramez Ashraf

unread,
Mar 14, 2016, 7:51:00 PM3/14/16
to Django developers (Contributions to Django itself)
May i add to the proposal suffixing the project_name inner directory (the one containing settings.py) with '_proj' 
Usually i start project called 'my_client_name', then i want an app called 'my_client_name' too, 
usually i do NOT want my main app called "my_client_name_app"..  table names just looks ugly and unnecessarily long in this case.
Nor i want my main/parent directory to be called "my_client_name_proj" , unnecessarily long for nginx/uwsgi/other paths.


tl;dr
project_name/
  ..
  project_name+ "_proj"/
  app1/
  ..

Regards;

Curtis Maloney

unread,
Mar 14, 2016, 8:26:59 PM3/14/16
to django-d...@googlegroups.com
Well, you could use:

mkdir my_client_name
django-admin startproject project my_client_name/

So it will create my_client_name/project/settings.py, and leave the
namespace clear for you to create my_client_name/my_client_name/ as your
app...

--
Curtis
> --
> You received this message because you are subscribed to the Google
> Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-develop...@googlegroups.com
> <mailto:django-develop...@googlegroups.com>.
> To post to this group, send email to django-d...@googlegroups.com
> <mailto:django-d...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/de495e35-ecad-409c-a5d2-f30512c36931%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/de495e35-ecad-409c-a5d2-f30512c36931%40googlegroups.com?utm_medium=email&utm_source=footer>.

Ramez Ashraf

unread,
Mar 14, 2016, 8:42:25 PM3/14/16
to django-d...@googlegroups.com
That's a solution :-) Thanks!
I personally create my projects/apps via a script with customized templates.

But for new comers, they will suffer from adding "_app" to their main app. I know i did at one point.:-)

All the best.


--
You received this message because you are subscribed to a topic in the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/X1exTiEybMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ramez Ashraf
Co-Founder and lead developer radev.io

Reply all
Reply to author
Forward
0 new messages