I’m trying to migrate an old django application to django 1.5, There are 745 urls in different html files as this way:
{% url url_name %}
If I’m not wrong, this was deprecated and can’t be used anymore from django 1.5 (as said here), and I have to transform all of them into:
{% url 'url_name' %}
Any idea to do this without going crazy? Maybe, some kind of script, I dont know…
I can’t imagine a way to do it with replace in path.
I’m probably missing something obvious.
NOTE: This command is destructive. Use version control or backup your templates directory before running it.
You can use sed. From your template directory (or directories) run
The expression matches
{% url [view name], so arguments provided to the url template tag will be unaffected/unchanged.To run it recursively,
This sed command assumes your view names only contain alphanumerics, colons, dashes, periods and underscores – no other special characters. Now supports namespaced views.
Tested against the tags in this Django 1.4 url template tag Gist