From 3cea556f67b770411a1f2e1e2df62fea1fba623e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jmeno=20P=C5=99=C3=ADjmen=C3=AD?= Date: Thu, 4 Nov 2021 10:55:36 +0100 Subject: [PATCH] detail novinky --- databaze/urls.py | 3 ++- novinky/templates/novinky/index.html | 3 +++ novinky/templates/novinky/newitem.html | 14 ++++++++++++++ novinky/views.py | 8 ++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 novinky/templates/novinky/newitem.html diff --git a/databaze/urls.py b/databaze/urls.py index c3014a8..9b580fd 100644 --- a/databaze/urls.py +++ b/databaze/urls.py @@ -15,9 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import path -from novinky.views import index +from novinky.views import index, newitem urlpatterns = [ path('admin/', admin.site.urls), + path('novinka//', newitem, name="newitem"), path('', index, name="index"), ] diff --git a/novinky/templates/novinky/index.html b/novinky/templates/novinky/index.html index a2e8e9c..c2b938b 100644 --- a/novinky/templates/novinky/index.html +++ b/novinky/templates/novinky/index.html @@ -10,6 +10,9 @@

{{ novinka.zprava|truncatewords:10 }}

+

+ číst dál +

{% endfor %} {% endblock %} \ No newline at end of file diff --git a/novinky/templates/novinky/newitem.html b/novinky/templates/novinky/newitem.html new file mode 100644 index 0000000..b1ec2ab --- /dev/null +++ b/novinky/templates/novinky/newitem.html @@ -0,0 +1,14 @@ +{% extends "novinky/base.html" %} + +{% block content %} +

{{ novinka.titulek }}

+ {{ novinka.datum|date:"j. E Y G:i" }}
+ {{ novinka.autor }} +

+ {{ novinka.zprava }} +

+

+ zpět +

+ +{% endblock %} diff --git a/novinky/views.py b/novinky/views.py index 9877ccd..b5a4407 100644 --- a/novinky/views.py +++ b/novinky/views.py @@ -8,3 +8,11 @@ def index(request): "novinky": novinky, } return render(request, "novinky/index.html", context) + + +def newitem(request, new_id): + novinka = Novinka.objects.get(id=new_id) + context = { + "novinka": novinka, + } + return render(request, "novinky/newitem.html", context)