I am using Django 1.5.1
I am in need of passing the view name as a variable to my template.
Here is the relevant part of my view
return render(request, 'testcases/execute.html', {
'table': table ,
'submit_view': 'testcase_execute' ,
"project": project})
And here is the relevant part of my template
<form method="POST" action="{% url submit_view project.slug %}">
{% render_table table %}
<input type="submit"/>
</form>
As you can see, I am trying pass the view name ('testcase_execute') as a variable (submit_view)to the template.
But this way I am getting the error
'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs.
I dont see whats wrong, as per this SO thread (How to pass a variable to {% url %} tag in django?), if I need to use a variable with the url tag, I should not put quotes. There also exists other SO threads which tells the same thing.
I saw another SO thread (Passing variable urlname to url tag in django template) which states this kind of thing (using a variable with url tag) isnt supported, I should be using django-reversetags for this.
Please throw some light on this- Is there an official (Django core ) way of doing this or should I go with django-reversetags