D
D
dr sbtn2016-05-23 20:23:20
Django
dr sbtn, 2016-05-23 20:23:20

How to make logout button in django?

code like this. well, plus I added a line to the url

class LogoutView(View):
    def get(self, request):
        logout(request)
        return HttpResponseRedirect("/")

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
Cyber_bober, 2016-05-23
@dawasaturday

<a href="/logout">Logout</a>

A
Alexey Ovdienko, 2016-05-23
@doubledare

<a href="{% url "users:auth_logout" %}" class="btn">

If you have a different path to the logout, you can use the url tag

B
Bulat Kurbangaliev, 2016-05-24
@ilov3

Only post request on important actions (to which the logout applies)

E
Evgeny Maltsev, 2016-05-24
@hellpirat

You can take Django urls

url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='user_logout'),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question