Opened 5 years ago
Closed 5 years ago
#31497 closed Bug (worksforme)
get_static_prefix() as variable in a template doesn't work.
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 (last modified by )
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 %} {% tkrempser 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.
Change History (1)
comment:1 by , 5 years ago
Component: | Documentation → contrib.staticfiles |
---|---|
Description: | modified (diff) |
Resolution: | → worksforme |
Status: | new → closed |
Summary: | get_static_prefix as variable in a template not working → get_static_prefix() as variable in a template doesn't work. |
Note:
See TracTickets
for help on using tickets.
Thanks for this ticket, however it works for me, it can be some issue in your templates. Please use one of support channels.