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 %} + + 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 %} 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 %} 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 %} 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' 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), ]