0

I'm working on a website for an internship. I've implemented a logout button but when I logout, after the user deconnection, I have a redirection on the home page, but I don't want this, for example if I'm in url.com/toto/tata, after the logout I would like to stay in this path and not have a rediction to url.com/home.

<form method="POST" action="{% url "account_logout" %}" class="form-horizontal">
    {% csrf_token %}                                     
    <div class="form-actions">
        <button type="submit">Logout</button>
    </div>
</form>
hissroth
  • 251
  • 2
  • 17

1 Answers1

2

Simply add a next input to your logout form as follows:

<input type="hidden" name="next" value="{{ request.path }}">
Selcuk
  • 57,004
  • 12
  • 102
  • 110