added logout function

This commit is contained in:
iou1name 2018-08-10 18:57:28 -04:00
parent 8df4347932
commit 6e700359ce
8 changed files with 41 additions and 0 deletions

0
logout/__init__.py Normal file
View File

3
logout/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
logout/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class LogoutConfig(AppConfig):
name = 'logout'

View File

3
logout/models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
logout/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

12
logout/urls.py Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env python3
"""
Logout app URL configuration.
"""
from django.urls import path
from . import views
app_name = 'logout'
urlpatterns = [
path('', views.index, name='index'),
]

15
logout/views.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
"""
/logout app views.
"""
from django.contrib import messages
from django.shortcuts import redirect
from django.contrib.auth import logout
def index(request):
"""
Logs the user out.
"""
logout(request)
messages.success(request, "Logged out")
return redirect('homepage:index')