Jorge Con Jota
Jorge Con Jota

Reputation: 489

Django {{ block.super }} not working in a particular case

I'm trying to extend a template which contains this block:

    {% block headerjs %}
    <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
    <script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>
    {% endblock %}

To extend it, I'm using {{ block.super }} :

{% block headerjs %}
{{ block.super }}
<script type="text/javascript" src="{{ STATIC_URL }}js/formhandler.js"></script>
{% endblock %}

It is not working, {{ block.super }} is empty. I have noticed that <script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script> is the reason. When I don't load this script, everything works fine. Does anyone know why?

Upvotes: 5

Views: 1576

Answers (1)

Maxime Lorant
Maxime Lorant

Reputation: 36151

Since Django 1.5, you have to put quotes around views names in the {% url %} template tag. Otherwise, it'll be considered as a context variable now (so it'll search the variable django if exists and get its attribute views and so on...).
The correct version, as pointed out in comments is:

<script type="text/javascript" src="{% url 'django.views.i18n.javascript_catalog' %}"></script>

Maybe it was working before because you were using Django <= 1.4.

Upvotes: 1

Related Questions