Dr Sheldon
Dr Sheldon

Reputation: 186

How to use a button to point to an existing url

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

Answers (2)

Tech
Tech

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

willeM_ Van Onsem
willeM_ Van Onsem

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

Related Questions