Reputation: 186
I'm new to django, here i've to point a button to an existing url
<form> <input type="button" value="Put Your Text Here" onclick="window.location.href='/polls/{{ question.id }}/results/'" />
</form>
here i've created a button that points to a perticular url. is there any oprtimized methods available?
Upvotes: 3
Views: 134
Reputation: 925
<li><a href="/polls/{{ question.question_id }}/">{{ question.question_text }}</a></li><a href="/polls/{{ question.question_id }}/results/" title="{{ question }} Results"><button type='submit'> Result</button></a>
Upvotes: 0
Reputation: 476503
You can make use of the {% url … %}
template tag [Django-doc]:
<li>
<a href="{% url 'detail' question_id=question.pk">
{{ question.question_text }}</a></li>
<button type='submit'> Result
</button>
</a>
</li>
Upvotes: 2