Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

MaZZly opened this issue Sep 29, 2015 · 3 comments

Comments

@MaZZly
Copy link

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
Copy link
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
Copy link
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
Copy link
Owner

evansd commented Oct 30, 2015

Assuming this resolved the issue.

@evansd evansd closed this as completed Oct 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants