Issue
I can't find any solution on any article so I'm asking here. I'd like to make button which is gonna redirect user to specific url. I have already did it this way:
<button onclick="location.href='create_recipe/'" type="button" >Create new Recipe</button>
but instead of passing whole link I'd like to use {% url 'some_view' %}
but I do not have an idea how I should do that.
Is it even possible to do that ?
It has to be <button>
,
edit:
something like:
<button type="button" class="btn btn-outline-secondary"><a href="{% url 'index' %}">Create new Recipe</a></button>
also does not work
Solution
You can do this by adding this to the button:
onclick="goToSomeView()"
And then add this in script tag of html file:
<script type="text/javascript">
function goToSomeView(){
document.location.href = "{% url 'some_view' %}"
}
</script>
Answered By - nigel239
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.