startproject values for STATICFILES_DIRS and TEMPLATES

94 views
Skip to first unread message

René Fleschenberg

unread,
Nov 7, 2015, 10:16:26 PM11/7/15
to Django developers (Contributions to Django itself)
Hi,

It is quite common to configure TEMPLATES and STATICFILES_DIRS such that you
can override the templates and static files of installed apps from some
central location.

Maybe startproject should actually generate settings to do this by default?

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)

Or maybe:

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'mysite', 'static'),
)

In my experience, this is a real pain point for beginners, and doing this
shouldn't hurt anyone. What do you think?

Also, do you think that templates and static files should be treated
differently in this regard? The docs currently suggest such a configuration
for static files, but not for templates. I'd argue that it's more important
for templates, but it cannot harm to do it for both.

--
René Fleschenberg

Aymeric Augustin

unread,
Nov 8, 2015, 3:03:02 AM11/8/15
to django-d...@googlegroups.com
Hello René,

The current built-in projet template is designed to provide the minimal set of
settings required for a functional admin and a good level of security. (A few
months ago I would have just said "a functional admin", but a new setting was
added since then.)

As far as I can tell, the main argument for including STATICFILES_DIRS is that
it would encourage developers to keep their frontend in a single place instead
of scattering it across installed applications, as shown by Emma Delescolle at
DjangoCon Europe 2015.

Considering that I included TEMPLATES['default']['DIRS'] = [] in the templates
refactor, I can hardly be against including STATICFILES_DIRS = [] as well.
(I'm the self-proclaimed guardian of the minimialistic default settings file.)

That said, in my experience, the bigger pain point has been the requirement to
set STATIC_ROOT before deploying. Has anyone else noticed that? Should we do
something about it as well?

Including one more setting in the default project template doesn't hurt much.
It's the cumulative effect that makes the default settings module long and
unwieldy. I noticed that many developers are reluctant to edit out the bits
they don't need. That's why I believe it's useful to keep it minimal.

--
Aymeric.
> --
> 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 http://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/8237964.u2MXdYcyU2%40rex.
> For more options, visit https://groups.google.com/d/optout.

Collin Anderson

unread,
Nov 9, 2015, 2:25:41 PM11/9/15
to Django developers (Contributions to Django itself)
I wouldn't mind having these in the project template. They're already the example values in the docs. It could make it slightly easier for beginners.

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

TEMPLATES
= [
   
{
       
'BACKEND': 'django.template.backends.django.DjangoTemplates',
       
'DIRS': [os.path.join(BASE_DIR, 'templates')],
       
'APP_DIRS': True,
   
}
]
Reply all
Reply to author
Forward
0 new messages