#18942: Documentation of `{% get_static_prefix %}` unclear
------------------------------------------------+------------------------
               Reporter:  aaugustin             |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Documentation         |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 The [https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
 :templatetag-get_static_prefix documentation] says:

 > If you’re not using !RequestContext, or if you need more control over
 exactly where and how STATIC_URL is injected into the template, you can
 use the get_static_prefix template tag instead:

 ----

 `{% get_static_prefix %}` was introduced in [33d8fcde8a]. It essentially
 returns `iri_to_uri(settings.STATIC_URL)`.

 The documentation implies that `{% get_static_prefix %}` is equivalent to
 `{{ STATIC_URL }}`. In theory it isn't, because the `static` context
 processor doesn't apply `iri_to_uri`, while the `get_static_prefix` tag
 does. I don't know if it matters in practice.

 Furthermore, I don't understand how `{% get_static_prefix %}` gives me
 "more control".

 I can see several ways to resolve this, the simplest would be:
 - also apply `iri_to_uri` in the `static` context processor (and in the
 `media` context processor) for consistency
 - simply state that `{% get_static_prefix %}` is an alternative to `{{
 STATIC_URL }}` that doesn't require a context processor

 ----

 There's also a built-in `{% static %}` tag, and another version provided
 by `contrib.staticfiles` since [1d32bdd3c9].

 Having four different ways to achieve the same result — with various
 degrees of sophistication — is confusing. Is there a good reason to keep
 `{% get_static_prefix %}` and `{{ STATIC_URL }}`, if they do essentially
 the same thing? IOW is the ability not to use the `static` request context
 processor useful?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18942>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to