1๐
If you have type="submit"
, sounds like you are using a form, right? If you do have a form, your url shouldnโt be on the button but on the form action
attribute.
You need to give your url a name, like:
url(r'^details/$', TemplateView.as_view(template_name='details.html'), name="details"),
Then your action would be:
action="{% url 'details' %}"
Read some resource online to learn how to use a form action.
I suggest you learn some html basics before jumping into django development, it would save your time wondering these kind of questions.
If you are not using a form, you might just need an <a>
tag that looks like a button with css decoration. If you are using bootstrap, check out .btn
class in the documentation.
0๐
It would be better to avoid javascript and just make a really simple form:
<form method="GET" action="{% url 'details_page' %}">
<button type="submit">View</button>
</form>
But you also need to name the route like so:
url(r'^details/$', TemplateView.as_view(template_name='details.html'), name="details_page")
Links are still preferrable though. It would be better to use some sort of CSS to make links and buttons look the same so you can use them interchangeably like bootstrap.