Browse Source

ab 5 sql

master
Janko Hartwig 5 years ago
parent
commit
95498d98ef

+ 3
- 0
djp/djp/settings.py 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


+ 24
- 0
djp/polls/migrations/0001_initial.py 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()),
],
),
]

+ 5
- 0
djp/polls/models.py 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()

+ 9
- 1
djp/polls/views.py 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.

+ 4
- 0
djp/templates/polls/index.html 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>


Loading…
Cancel
Save