This commit is contained in:
Janko Hartwig 2018-11-12 17:13:49 +01:00
parent 21f17ec603
commit 95498d98ef
5 changed files with 45 additions and 1 deletions

View File

@ -37,8 +37,10 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls.apps.PollsConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
@ -82,6 +84,7 @@ DATABASES = {
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

View File

@ -0,0 +1,24 @@
# Generated by Django 2.1.3 on 2018-11-12 15:06
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Notice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('notice_title', models.CharField(max_length=80)),
('notice_text', models.CharField(max_length=400)),
('pub_start', models.DateTimeField()),
('pub_end', models.DateTimeField()),
],
),
]

View File

@ -1,3 +1,8 @@
from django.db import models
# Create your models here.
class Notice(models.Model):
notice_title = models.CharField(max_length=80)
notice_text = models.CharField(max_length=400)
pub_start = models.DateTimeField()
pub_end = models.DateTimeField()

View File

@ -1,9 +1,17 @@
from django.http import HttpResponse
from django.shortcuts import render
import time
from django.utils import timezone
from datetime import timedelta
from polls.models import Notice
def index(request):
context = {'now' : time.strftime('%H:%M:%S', time.localtime())}
context = {'now' : time.strftime('%H:%M:%S', time.localtime()),
'posts' : Notice.objects.all() }
# start = timezone.now()
#end = start + timedelta(days=10)
#for n in Notice.objects.all():
# print(n.notice_title)
return render(request, 'polls/index.html', context)
# Create your views here.

View File

@ -8,6 +8,10 @@ Index
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1>Index der Polls-Applikation</h1>
{% for post in posts %}
<p>{{ post.notice_title }}</p>
<p>{{ post.notice_text }}</p>
{% endfor %}
</div>
</div>