From 5e5e30306ccbb716d25f14b55d643aa243fffd9a Mon Sep 17 00:00:00 2001 From: hartwigja62500 Date: Tue, 27 Nov 2018 15:32:49 +0100 Subject: [PATCH] prakt7 --- djp/djp/urls.py | 1 + djp/polls/urls.py | 4 +++- djp/polls/views.py | 2 ++ djp/templates/polls/index.html | 1 + djp/templates/registration/login.html | 21 +++++++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 djp/templates/registration/login.html diff --git a/djp/djp/urls.py b/djp/djp/urls.py index 2c9e307..0ac2f2e 100644 --- a/djp/djp/urls.py +++ b/djp/djp/urls.py @@ -18,5 +18,6 @@ from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), + url('accounts/', include('django.contrib.auth.urls')), url(r'^admin/', admin.site.urls), ] diff --git a/djp/polls/urls.py b/djp/polls/urls.py index 7f95bad..5007a78 100644 --- a/djp/polls/urls.py +++ b/djp/polls/urls.py @@ -1,4 +1,6 @@ -from django.conf.urls import url +from django.conf.urls import url, include, re_path + + from . import views diff --git a/djp/polls/views.py b/djp/polls/views.py index ea88691..2710d9d 100644 --- a/djp/polls/views.py +++ b/djp/polls/views.py @@ -1,6 +1,7 @@ from django.http import HttpResponse from django.shortcuts import render, redirect import time +from django.contrib.auth.decorators import login_required from polls.forms import NoticeForm from django.utils import timezone from datetime import timedelta @@ -15,6 +16,7 @@ def index(request): # print(n.notice_title) return render(request, 'polls/index.html', context) +@login_required def new(request): if request.method == "POST": form = NoticeForm(request.POST) diff --git a/djp/templates/polls/index.html b/djp/templates/polls/index.html index 2e3dbcd..367a294 100644 --- a/djp/templates/polls/index.html +++ b/djp/templates/polls/index.html @@ -19,6 +19,7 @@ Index

Neue Nachricht

+

Abmelden

{% endblock %} diff --git a/djp/templates/registration/login.html b/djp/templates/registration/login.html new file mode 100644 index 0000000..90dde3d --- /dev/null +++ b/djp/templates/registration/login.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} + +{% block title %} +Login +{% endblock %} + +{% block content %} + +
+ +
+ {% csrf_token %} + Benutzername: {{ form.username }}
+ Passwort: {{ form.password }}
+ + +
+ +
+ +{% endblock %} \ No newline at end of file