{% static %} doesn't include hash #43

Closed
MaZZly opened this Issue Sep 29, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@MaZZly

MaZZly commented Sep 29, 2015

Can't get the darn thing to work with
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

But with my own homebrewed combination of django-pipeline and whitenoise:

from pipeline.storage import PipelineMixin
from whitenoise.django import GzipManifestStaticFilesStorage

class GzipManifestPipelineStorage(PipelineMixin, GzipManifestStaticFilesStorage):
    pass

and then
STATICFILES_STORAGE = 'app.storages.GzipManifestPipelineStorage'
at least the {% compressed_css %} tag of django-pipeline outputs the hash. but {%static%} still doesn't

So tl;dr: Following documentation the {%static%} tag outputs style.css instead of style.hash.css

@evansd

This comment has been minimized.

Show comment
Hide comment
@evansd

evansd Sep 30, 2015

Owner

It could be that you're missing the {% load static %} declaration at the top of your template file.

EDIT: Sorry that was a typo: this should be {% load staticfiles %} or, if you want to be explicit {% load static from staticfiles %} but both do the same thing.

Owner

evansd commented Sep 30, 2015

It could be that you're missing the {% load static %} declaration at the top of your template file.

EDIT: Sorry that was a typo: this should be {% load staticfiles %} or, if you want to be explicit {% load static from staticfiles %} but both do the same thing.

@evansd

This comment has been minimized.

Show comment
Hide comment
@evansd

evansd Oct 19, 2015

Owner

@RyanBalfanz your comment seems to have disappeared from github, so I'm copying here for reference:

@evansd Should we {% load static %} or {% load static from staticfiles %} as in the docs?

It seems like different suggestions exists from different authorities -- If one doesn't read the WhiteNoise Docs and just follows Django's static files how-to and Heroku's django-assets article they wouldn't know to prefer the latter. It's a bit unclear IMO.

Sorry, that was a typo. It should be {% load staticfiles %} or {% load static from staticfiles %}. Both do exactly the same thing but the latter is a bit more explicit about which tag is being imported.

It's a confusing feature of Django that the static tag behaves differently depending on whether you've loaded the staticfiles tag library or not. But for backwards compatibility reasons that isn't going to change so we just have to work with it.

I think the Heroku docs should be amended to mention that you should load the staticfiles library in your templates. Do you mind making that suggestion to them? There's a feedback form on the docs page.

Owner

evansd commented Oct 19, 2015

@RyanBalfanz your comment seems to have disappeared from github, so I'm copying here for reference:

@evansd Should we {% load static %} or {% load static from staticfiles %} as in the docs?

It seems like different suggestions exists from different authorities -- If one doesn't read the WhiteNoise Docs and just follows Django's static files how-to and Heroku's django-assets article they wouldn't know to prefer the latter. It's a bit unclear IMO.

Sorry, that was a typo. It should be {% load staticfiles %} or {% load static from staticfiles %}. Both do exactly the same thing but the latter is a bit more explicit about which tag is being imported.

It's a confusing feature of Django that the static tag behaves differently depending on whether you've loaded the staticfiles tag library or not. But for backwards compatibility reasons that isn't going to change so we just have to work with it.

I think the Heroku docs should be amended to mention that you should load the staticfiles library in your templates. Do you mind making that suggestion to them? There's a feedback form on the docs page.

@evansd

This comment has been minimized.

Show comment
Hide comment
@evansd

evansd Oct 30, 2015

Owner

Assuming this resolved the issue.

Owner

evansd commented Oct 30, 2015

Assuming this resolved the issue.

@evansd evansd closed this Oct 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment