barciewicz
barciewicz

Reputation: 3783

Attach link to a button in Django

The following Django template code for opening a different page template works fine:

<p>
    <a id="selenium" href="{% url 'javascript:results' %}">Selenium</a>
</p>

However, I want the link to open upon button click, but the followng code does not work:

<button>
    <a id="selenium" href="{% url 'javascript:results' %}">Selenium</a>
</button>

How do I attach a link to a button in Django then?

Upvotes: 1

Views: 4251

Answers (1)

Prakash Palnati
Prakash Palnati

Reputation: 3409

This is HTML problem which you can solve in many ways. One such way is below.

<form>
    <button formaction="{% url 'javascript:results' %}">Selenium</button>
</form>

Upvotes: 3

Related Questions