Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#15202 closed (invalid)

Changeset 15376 breaks implementation

Reported by: Lior Sion Owned by:
Component: contrib.staticfiles Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The changeset 15376 ( added a test that caused most known implementations (for example, here: - there's a lot of sense in letting django look for static files on the STATIC_ROOT directory

Change History (3)

comment:1 Changed 12 years ago by Carl Meyer

Resolution: invalid
Status: newclosed

No, adding STATIC_ROOT to STATICFILES_DIRS is not sensible, and will break things. STATIC_ROOT is a _destination_ directory, not a _source_ directory for static files. Adding STATIC_ROOT to STATICFILES_DIRS is, in essence, asking "collectstatic" to do an infinite recursive copy. The fact that some people are doing this indicates even more clearly the need for the code check to alert them that they are misunderstanding how these settings work.

The docs were not as clear on this point as they should have been, and in fact contained some outright misleading statements about STATIC_ROOT, so it's not surprising people have been confused about this. I reworked them yesterday and today to hopefully provide better clarity before the 1.3 release.

comment:2 Changed 12 years ago by Lior Sion

Needs documentation: set

I understand what you mean on destination vs. source, however, I would think most of the time the destination of staticfile collection would be the source for my STATICFILES_DIRS -> this is why I used staticfiles collection.

This is what I see in my mind:

src->templates->html files
static->css,js, img files

static directory is outside the src directory.

STATIC_ROOT is used as destination to which static files are collected (in my example it would be the static dir)
however, since I want my static files to be provided from there, that's directory is inside my STATICFILES_DIRS as well, no?

If not - I would appreciate some more information on how you think the setup would be implemented.


comment:3 Changed 12 years ago by Carl Meyer

Needs documentation: unset

No, you're misunderstanding. STATICFILES_DIRS allows you to add sources for static files: this is where you keep your static files. In development, staticfiles will automatically serve things from your staticfiles sources (app static/ subdirs, and STATICFILES_DIRS). STATIC_ROOT is completely unnecessary in local development. STATIC_ROOT (and the collectstatic command) are only needed for deployment with a real webserver. The collectstatic command copies (or symlinks) static files from all sources into STATIC_ROOT, where you can configure your front-end webserver to serve them.

Trac isn't a support resource, so if this still isn't clear to you, please don't follow up here. Review the staticfiles docs (they've been significantly updated in the last few days for clarity on these exact points) and if it still isn't making sense ask in #django on IRC (I'm usually there and would be glad to help) or on the django-users mailing list.

Note: See TracTickets for help on using tickets.
Back to Top