How to make a button-click redirect to another URL, in Django?

Viewed 29973

I made an HTML-button, in the code shown below:

<div style="" class="button-box" >

    <button>Useradministration</button>

</div>

When I click on it, I want it to redirect the user to the /admin-url.

How should I do this? How do I make Django "know" that the button has been clicked?

Thank you so much for your time!

4 Answers

you can use like this:

<a class="btn btn-primary" href="/admin-url">Useradministration</a>

For button Click Navigation to another URL in Django

<button onclick="location.href = '/pageurl'">Click</button>

For a button-click redirect to another URL in Django :

<button><a href="/admin">Click</a></button>


Another way :

<button onclick="window.location='projects';">Projects</button>
<a href="./your-url">
  <button>button text</button>
</a>
Related