Created
January 4, 2014 02:54
-
-
Save laozhu/8250910 to your computer and use it in GitHub Desktop.
Class Based Logout View of Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.core.urlresolvers import reverse | |
from django.contrib.auth import logout | |
from django.views.generic import RedirectView | |
class LogoutView(RedirectView): | |
""" | |
A view that logout user and redirect to homepage. | |
""" | |
permanent = False | |
query_string = True | |
pattern_name = 'home' | |
def get_redirect_url(self, *args, **kwargs): | |
""" | |
Logout user and redirect to target url. | |
""" | |
if self.request.user.is_authenticated(): | |
logout(self.request) | |
return super(LogoutView, self).get_redirect_url(*args, **kwargs) |
It's not working in Django 3.1. Can you rewrite it to Django 3.1 ?
no
Why not?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not working in Django 3.1. Can you rewrite it to Django 3.1 ?