Browse Source

novinka

master
Pavel Škrabánek 3 years ago
parent
commit
351938c520
  1. 3
      databaze/urls.py
  2. 3
      novinky/templates/novinky/index.html
  3. 10
      novinky/templates/novinky/novinka.html
  4. 4
      novinky/views.py

3
databaze/urls.py

@ -16,8 +16,9 @@ Including another URLconf
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path
from novinky.views import index
from novinky.views import index,novinka
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('novinka/<int:novinka_id>/', novinka, name="novinka"),
path('', index, name="index"), path('', index, name="index"),
] ]

3
novinky/templates/novinky/index.html

@ -8,7 +8,8 @@
{{ novinka.autor }} <br> {{ novinka.autor }} <br>
{{ novinka.datum }} <br> {{ novinka.datum }} <br>
<p> <p>
{{ novinka.zprava }}
{{ novinka.zprava|truncatewords:5 }}
<a href="{% url 'novinka' novinka.id %}">vice</a>
</p> </p>
{% endfor %} {% endfor %}

10
novinky/templates/novinky/novinka.html

@ -0,0 +1,10 @@
{% extends "novinky/base.html" %}
{% block content %}
<h1>Zde nic neni</h1>
<a href="{% url 'index' %}">zpět</a>
{% endblock %}

4
novinky/views.py

@ -10,3 +10,7 @@ def index(request):
"novinky": novinky, "novinky": novinky,
} }
return render(request, "novinky/index.html", context) return render(request, "novinky/index.html", context)
def novinka(request, novinka_id):
return render(request, "novinky/novinka.html")
Loading…
Cancel
Save