Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15202 closed (invalid)

Changeset 15376 breaks implementation

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

Description

The changeset 15376 (http://code.djangoproject.com/changeset/15376) added a test that caused most known implementations (for example, here: http://stackoverflow.com/questions/4565935/django-staticfiles-app-help) - there's a lot of sense in letting django look for static files on the STATIC_ROOT directory

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 3 years ago by liorsion

  • 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.

thanks

comment:3 Changed 3 years ago by carljm

  • 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.