This commit is contained in:
2018-11-12 17:13:49 +01:00
parent 21f17ec603
commit 95498d98ef
5 changed files with 45 additions and 1 deletions
+24
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
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
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.