I am a novice Django user trying to create a push button, which links to another page in my site when clicked. I've tried a few different examples which I've found, but none seem to be working for me...
As an example, why is this not working?
<form method="link" action="{% url 'gui' %}">
<input type="button" value="Start">
</form>
Here, 'gui' is the name I have given to my link in urls.py to the desired page.
I am also fairly new to HTML in general, so it may be my HTML that is wrong...
Thank you.
Is there any particular reason you're using both a form
and a button
?
Can you use an a
(anchor tag)?
<a href="{% url 'appname.nameOfFunctionInViews' %}">Click here</a>
If you want to use a form
, please post your urls.py
.
To create a button that can be clicked and redirect to another link, you can wrap <button></button>
around <a></a>
, which worked for me:
<button type="button">
<a href="{% url 'name_of_your_view' %}">Click here!</a>
</button>
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