Browse Source

výpis novinek

master
Lukáš Kubíček 4 years ago
parent
commit
624f8e412b
  1. 1
      novinky/models.py
  2. 16
      novinky/templates/novinky/index.html
  3. 9
      novinky/views.py

1
novinky/models.py

@ -13,6 +13,7 @@ class Novinka(models.Model):
return self.titulek return self.titulek
class Meta: class Meta:
ordering = ["-datum", ]
verbose_name = "Novinka" verbose_name = "Novinka"
verbose_name_plural = "Novinky" verbose_name_plural = "Novinky"

16
novinky/templates/novinky/index.html

@ -1 +1,15 @@
{% extends "novinky/base.html" %}
{% extends "novinky/base.html" %}
{% block content %}
<h1>Novinky</h1>
{% for novinka in novinky %}
<h2>{{ novinka.titulek }}</h2>
{{ novinka.autor }} <br>
{{ novinka.datum }} <br>
<p>
{{ novinka.zprava }}
</p>
{% endfor %}
{% endblock %}

9
novinky/views.py

@ -1,5 +1,12 @@
from django.shortcuts import render from django.shortcuts import render
from novinky.models import Novinka
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, "novinky/index.html")
novinky = Novinka.objects.all()
context = {
"novinky": novinky,
}
return render(request, "novinky/index.html", context)
Loading…
Cancel
Save