#31497: get_static_prefix() as variable in a template doesn't work.
-------------------------------------+-------------------------------------
     Reporter:  Thiago Krempser      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  contrib.staticfiles  |                  Version:  3.0
     Severity:  Normal               |               Resolution:
                                     |  worksforme
     Keywords:                       |             Triage Stage:
  get_static_prefix,static           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * status:  new => closed
 * resolution:   => worksforme
 * component:  Documentation => contrib.staticfiles


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

New 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 %}
 {% 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.

--

Comment:

 Thanks for this ticket, however it works for me, it can be some issue in
 your templates. Please use one of
 [https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
 support channels].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31497#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.55db10d96849520b1e0030b076e7f330%40djangoproject.com.

Reply via email to