urlpatterns = [ | urlpatterns = [ | ||||
url(r'^polls/', include('polls.urls')), | url(r'^polls/', include('polls.urls')), | ||||
url('accounts/', include('django.contrib.auth.urls')), | |||||
url(r'^admin/', admin.site.urls), | url(r'^admin/', admin.site.urls), | ||||
] | ] |
from django.conf.urls import url | |||||
from django.conf.urls import url, include, re_path | |||||
from . import views | from . import views | ||||
from django.http import HttpResponse | from django.http import HttpResponse | ||||
from django.shortcuts import render, redirect | from django.shortcuts import render, redirect | ||||
import time | import time | ||||
from django.contrib.auth.decorators import login_required | |||||
from polls.forms import NoticeForm | from polls.forms import NoticeForm | ||||
from django.utils import timezone | from django.utils import timezone | ||||
from datetime import timedelta | from datetime import timedelta | ||||
# print(n.notice_title) | # print(n.notice_title) | ||||
return render(request, 'polls/index.html', context) | return render(request, 'polls/index.html', context) | ||||
@login_required | |||||
def new(request): | def new(request): | ||||
if request.method == "POST": | if request.method == "POST": | ||||
form = NoticeForm(request.POST) | form = NoticeForm(request.POST) |
<p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p> | <p><a href="{% url 'new' %}" class="btn btn-info" role="button">Neue Nachricht</a></p> | ||||
<p><a href="{% url 'logout' %}" class="btn btn-warning">Abmelden</a></p> | |||||
{% endblock %} | {% endblock %} | ||||
{% extends 'base.html' %} | |||||
{% block title %} | |||||
Login | |||||
{% endblock %} | |||||
{% block content %} | |||||
<div class="container"> | |||||
<form method="post" action="{% url 'login' %}"> | |||||
{% csrf_token %} | |||||
Benutzername: {{ form.username }} <br> | |||||
Passwort: {{ form.password }} <br> | |||||
<button type="submit" class="btn btn-default">Anmelden</button> | |||||
<input type="hidden" name="next" value="{{ next }}" /> | |||||
</form> | |||||
</div> | |||||
{% endblock %} |