I have the following url in my urls.py
url(r'^inline-formset/$', 'order.views.addrow', {'form_class': OrderedItemForm}, name='addrow'),
Now i would like to reference this url from a form button but i am not getting the syntax right.
This works:
<a href="{% url 'addrow' %}">New Line</a>
This has the wrong syntax, please assist
<input class="btn btn-success" type="button" value="New Line" onclick="location.href="{% url 'addrow' %}"" />
Your specific problem is that you have a conflict with quote types. Use this instead:
onclick="location.href='{% url 'customeroverview' %}'"
but note that this is not really a good way of doing things. If you just want a link that looks like a button, then have a normal a href
and use CSS to style it like a button. In Bootstrap, for example, you can use the "btn btn-*" classes on any element to make it look like a button.
Make sure you have a url specified in urls.py for "customeroverview"
something like
url(r'^xxx/$', 'xxx.views.function', name='customeroverview')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With