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_URL not defined in templates #175

Open
tisdall opened this issue Sep 1, 2016 · 2 comments
Open

STATIC_URL not defined in templates #175

tisdall opened this issue Sep 1, 2016 · 2 comments

Comments

@tisdall
Copy link

tisdall commented Sep 1, 2016

I'm trying to use the map widget and I noticed in the template {{ STATIC_URL}}. It seems that only gets added if you add django.template.context_processors.static to your context processors. The Django docs seems to suggest using the static tag which doesn't require the context processor.

So instead of:
background-image: url("{{ STATIC_URL }}floppyforms/gis/img/move_vertex_on.png");

it should be:
background-image: url("{% static "floppyforms/gis/img/move_vertex_on.png" %}");
with {% load static %} up at the top.

So, I guess you could leave it as, but I didn't notice anything in the docs saying that you needed to have the above mentioned context processor added for some of the default templates to work. The static tag works without any changes to settings.

@gregmuellegger
Copy link
Collaborator

Yes, you are right. The {% static %} approach is prefered over the one using the context processor. floppyforms comes from an age where only {{ STATIC_URL }} existed.

We should start dropping the support for those ancient releases.

I'm happy to accept a Pull Request that changes the static use, if you like to prepare one.

@tisdall
Copy link
Author

tisdall commented Sep 2, 2016

I'm a little confused about compatibility with older releases... The context processor you included in your tests seems to have been added in 1.8 (looking at github, it seems they used to be in django.core.context_processors). How are the tests passing for version 1.4 - 1.7 if they're including context processors that aren't there? (I'm referring to them being referenced in tests/settings.py)

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