File tree Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Expand file tree Collapse file tree 3 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 1
1
from django .shortcuts import render , redirect
2
- from django .contrib .auth import login , authenticate
2
+ from django .contrib .auth import login , authenticate , logout
3
3
from account .forms import RegistrationForm
4
4
5
5
@@ -23,5 +23,10 @@ def registration_view(request):
23
23
return render (request , 'account/register.html' , context )
24
24
25
25
26
+ def logout_view (request ):
27
+ logout (request )
28
+ return redirect ('/' )
29
+
30
+
26
31
27
32
Original file line number Diff line number Diff line change 22
22
23
23
from account .views import (
24
24
registration_view ,
25
+ logout_view ,
25
26
)
26
27
27
28
urlpatterns = [
28
29
path ('admin/' , admin .site .urls ),
29
30
path ('' , home_screen_view , name = "home" ),
30
31
path ('register/' , registration_view , name = "register" ),
32
+ path ('logout/' , logout_view , name = "logout" ),
31
33
]
Original file line number Diff line number Diff line change 2
2
< html lang =en >
3
3
4
4
< head >
5
- < div style ="border: 2px solid #000; ">
6
- < h1 > This is the Header</ h1 >
7
- </ div >
5
+ {% if request.user.is_authenticated %}
6
+ < p > Hello, {{request.user.username}} | < a href ="{% url 'logout' %} "> Logout</ a > </ p >
7
+ {% else %}
8
+ < p > < a href ="{% url 'register' %} "> Register</ a > | < a href ="# "> Login</ a > </ p >
9
+ {% endif %}
10
+ < hr >
11
+
8
12
</ head >
9
13
10
14
< body >
@@ -16,9 +20,8 @@ <h1>This is the Header</h1>
16
20
</ body >
17
21
18
22
< footer >
19
- < div style ="border: 2px solid #000; ">
20
- < h2 > This is the footer</ h2 >
21
- </ div >
23
+ < hr >
24
+ < p > CodingWithMitch Blog Course | 2019</ p >
22
25
</ footer >
23
26
24
27
</ html >
You can’t perform that action at this time.
0 commit comments