Git Product home page Git Product logo

Comments (3)

evansd avatar evansd commented on September 7, 2024

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.

from whitenoise.

evansd avatar evansd commented on September 7, 2024

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

from whitenoise.

evansd avatar evansd commented on September 7, 2024

Assuming this resolved the issue.

from whitenoise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.