Django: URL tag support with or without quotes (> 1.5) (older versions of Django)
Is there a way to support:
{% url myapp.views.index %}
and
{% url 'myapp.views.index' %}
both at the same time?
Why do this? I was told to change my entire dev environment to 1.6. which I did; however, surprisingly, the prod server still has django 1.4. The only big incompatibility is the URL tag.
Thanks in advance!
+3
source to share
1 answer
Load the future version of the url tag into your template, then you can also use the new syntax in Django 1.3 or 1.4.
{% load url from future %}
{% url 'myapp.views.index' %}
Loading a URL tag from the future was deprecated in Django 1.7 and removed in Django 1.9 . Once you've updated production to 1.5 or more, you can remove it from your templates.
+4
source to share