From 624f8e412b0fa88a3a1ea275e57f655e60f1ece6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kub=C3=AD=C4=8Dek?= Date: Fri, 5 Nov 2021 09:37:55 +0100 Subject: [PATCH] =?UTF-8?q?v=C3=BDpis=20novinek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- novinky/models.py | 1 + novinky/templates/novinky/index.html | 16 +++++++++++++++- novinky/views.py | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/novinky/models.py b/novinky/models.py index cb2a3ca..1ba0b4e 100644 --- a/novinky/models.py +++ b/novinky/models.py @@ -13,6 +13,7 @@ class Novinka(models.Model): return self.titulek class Meta: + ordering = ["-datum", ] verbose_name = "Novinka" verbose_name_plural = "Novinky" diff --git a/novinky/templates/novinky/index.html b/novinky/templates/novinky/index.html index 6f0488d..fcced62 100644 --- a/novinky/templates/novinky/index.html +++ b/novinky/templates/novinky/index.html @@ -1 +1,15 @@ -{% extends "novinky/base.html" %} \ No newline at end of file +{% extends "novinky/base.html" %} + +{% block content %} +

Novinky

+ + {% for novinka in novinky %} +

{{ novinka.titulek }}

+ {{ novinka.autor }}
+ {{ novinka.datum }}
+

+ {{ novinka.zprava }} +

+ {% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/novinky/views.py b/novinky/views.py index a8cbf7c..a616394 100644 --- a/novinky/views.py +++ b/novinky/views.py @@ -1,5 +1,12 @@ from django.shortcuts import render +from novinky.models import Novinka + + # Create your views here. def index(request): - return render(request, "novinky/index.html") \ No newline at end of file + novinky = Novinka.objects.all() + context = { + "novinky": novinky, + } + return render(request, "novinky/index.html", context) \ No newline at end of file