{% get_static_prefix %} Tag

puts STATIC_URL into the template.

Utility As Markdown

Argument(s)
as varname (optional)
Closing tag
Not required
Requires
{% load static %}

Documentation

Puts STATIC_URL into the template. Reach for it only where {% static %} cannot go — building a path in JavaScript, for instance.

Template

{% load static %}
<script>const STATIC = "{% get_static_prefix %}";</script>

Result

<script>const STATIC = "/static/";</script>

Use as to hold it in a variable when you need it more than once.

More Utility Tags

All Utility Tags


Did we get something wrong? Is there a use case for the get_static_prefix tag that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on August 20, 2026