Opened 5 years ago
Last modified 5 years ago
#31497 closed Bug
get_static_prefix as variable in a template not working — at Initial Version
Reported by: | Thiago Krempser | Owned by: | nobody |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 3.0 |
Severity: | Normal | Keywords: | get_static_prefix, static |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm using Django 3.0 and I tried to use this suggestion from the Django 3.0 documentation (https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#get-static-prefix):
{% load static %} {% get_static_prefix as STATIC_PREFIX %} <img src="{{ STATIC_PREFIX }}images/hi.jpg" alt="Hi!"> <img src="{{ STATIC_PREFIX }}images/hi2.jpg" alt="Hello!">
But STATIC_PREFIX variable is empty and nothing is printed on template.
Using the other suggestion:
{% load static %} <img src="{% get_static_prefix %}images/hi.jpg" alt="Hi!">
It works as expected.
Note:
See TracTickets
for help on using tickets.