From 75afcf60882322f885aaba7857f24f0318e030d1 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 08:42:38 +0530 Subject: [PATCH 1/6] Update urls.py --- metasearch/urls.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metasearch/urls.py b/metasearch/urls.py index 8e67f98..7e4156d 100644 --- a/metasearch/urls.py +++ b/metasearch/urls.py @@ -15,10 +15,13 @@ """ from django.conf.urls import url from django.contrib import admin +from django.contrib.auth import views as auth_views from main_app import views urlpatterns = [ url(r'^admin/', admin.site.urls), + url(r'^login/$',auth_views.login, name='login'), + url(r'^logout/$',auth_views.logout,name='logout'), url(r'^$',views.index), url(r'^result/',views.result), ] From bf9b4c7b52fd08a2f3fe0415b0214f6da4857bb6 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 08:57:21 +0530 Subject: [PATCH 2/6] Create login.html --- main_app/templates/registration/login.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 main_app/templates/registration/login.html diff --git a/main_app/templates/registration/login.html b/main_app/templates/registration/login.html new file mode 100644 index 0000000..e2355d2 --- /dev/null +++ b/main_app/templates/registration/login.html @@ -0,0 +1,12 @@ +{% extends 'base.html' %} + +{% block title %}Login{% endblock %} + +{% block content %} +

Login

+
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} From c27878f84d0fa3e37e8c55a6d3bddf7e3a4761e8 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 09:00:26 +0530 Subject: [PATCH 3/6] Update settings.py --- metasearch/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metasearch/settings.py b/metasearch/settings.py index f6d288f..d17585d 100644 --- a/metasearch/settings.py +++ b/metasearch/settings.py @@ -120,3 +120,5 @@ # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' + +LOGIN_REDIRECT_URL= 'home' From a50e3aa2554d77e51d1d1d543db232099a39cb47 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 09:05:23 +0530 Subject: [PATCH 4/6] Create logged_out.html --- main_app/templates/registration/logged_out.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 main_app/templates/registration/logged_out.html diff --git a/main_app/templates/registration/logged_out.html b/main_app/templates/registration/logged_out.html new file mode 100644 index 0000000..c866ef5 --- /dev/null +++ b/main_app/templates/registration/logged_out.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}See you!{% endblock %} + +{% block content %} +

Logged out

+

Log in agian.

+{% endblock %} From c07cea623dfa4dc97e9f8aba4e88750c8e650e30 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 09:07:13 +0530 Subject: [PATCH 5/6] Create home.html --- main_app/templates/registration/home.html | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 main_app/templates/registration/home.html diff --git a/main_app/templates/registration/home.html b/main_app/templates/registration/home.html new file mode 100644 index 0000000..be77a30 --- /dev/null +++ b/main_app/templates/registration/home.html @@ -0,0 +1,5 @@ +{% extends 'base.html' %} +{% block title %}Login{% endblock %} +{% block content %} +

Home

+{% endblock %} From a4a3c2d76015580eeb9dc178c3131415467aacd1 Mon Sep 17 00:00:00 2001 From: Shamitha Udupa Date: Wed, 8 Nov 2017 09:13:52 +0530 Subject: [PATCH 6/6] Create base.html --- main_app/templates/registration/base.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 main_app/templates/registration/base.html diff --git a/main_app/templates/registration/base.html b/main_app/templates/registration/base.html new file mode 100644 index 0000000..53f6074 --- /dev/null +++ b/main_app/templates/registration/base.html @@ -0,0 +1,15 @@ + + + + + {% block title %}Simple Login{% endblock %} + + + {% if user.is_authenticated %} + Hi {{ user.username }}! + Logout + {% else %} + Login + {% endif %} + +