Solution of 05
This commit is contained in:
parent
1d65d9c9a3
commit
fccc0f39d6
90
.gitignore
vendored
Normal file
90
.gitignore
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
|
||||
### Django ###
|
||||
*.log
|
||||
*.pot
|
||||
*.pyc
|
||||
**__pycache__/
|
||||
local_settings.py
|
||||
|
||||
.env
|
||||
**/db.sqlite3
|
||||
|
||||
# PyCharm
|
||||
**/.idea/
|
@ -37,6 +37,8 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'posts.apps.PostsConfig' #you could also add 'posts' to register everything in your app
|
||||
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
24
posts/migrations/0001_initial.py
Normal file
24
posts/migrations/0001_initial.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Generated by Django 2.1.3 on 2018-11-23 11:25
|
||||
|
||||
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()),
|
||||
],
|
||||
),
|
||||
]
|
@ -1,3 +1,7 @@
|
||||
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()
|
||||
|
@ -1,9 +1,20 @@
|
||||
from django.shortcuts import render
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
from posts.models import Notice
|
||||
# Create your views here.
|
||||
|
||||
|
||||
#Titel und die Texte aller Meldungen, deren Veröffentlichungsdatum vor und der Endedatum nach dem aktuellen Datum liegt.
|
||||
def home(request, value=""):
|
||||
now = timezone.now()
|
||||
notices = Notice.objects.all()
|
||||
display_notices = list()
|
||||
for notice in notices:
|
||||
if notice.pub_start < now and notice.pub_end > now:
|
||||
display_notices.append(notice)
|
||||
context = {
|
||||
"title": "Beboop",
|
||||
"message": value
|
||||
"notices": display_notices
|
||||
}
|
||||
return render(request, 'index.html', context)
|
@ -3,8 +3,10 @@
|
||||
{% block title %} {{ title }} {% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-6">My first post!</h1>
|
||||
<p class="lead">{{message}}</p>
|
||||
</div>
|
||||
{% for notice in notices %}
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-6">{{ notice.notice_title }}</h1>
|
||||
<p class="lead">{{notice.notice_text}}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock content %}
|
Loading…
x
Reference in New Issue
Block a user