Django: Can't render STATIC_URL from settings in template

You have to use context_instance=RequestContext(request) in your render_to_response, for example:

return render_to_response('my_template.html',
                          my_data_dictionary,
                          context_instance=RequestContext(request))

Or use the new shortcut render

As Dave pointed out, you should check if django.core.context_processors.static is in your TEMPLATE_CONTEXT_PROCESSORS variable in settings.py. As the docs said, it`s there by default.


It is not recommended to directly use the STATIC_URL variable. See the accepted answer in this question

Instead of

{{STATIC_URL}}stylesheets/tabs.css

use

{% load staticfiles %}
{% static 'stylesheets/tabs.css' %}

Tags:

Python

Django