Zobrazeni novinek na titulni strance
This commit is contained in:
parent
0983f397c5
commit
301e47c701
3 changed files with 46 additions and 16 deletions
|
@ -1,9 +0,0 @@
|
|||
{% block body %}
|
||||
{% for novinka in object_list %}
|
||||
<p>
|
||||
Tady bude novinka.
|
||||
{{ novinka.text }}
|
||||
</p>
|
||||
<img src='{{ novinka.obrazek.url }}'
|
||||
{% endfor%}
|
||||
{% endblock %}
|
|
@ -1,7 +1,46 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
HU!
|
||||
|
||||
{% block content %}
|
||||
Tady bude nadpis pro novinky.
|
||||
{% include 'seminar/novinky.html' %}
|
||||
|
||||
{# Uvitaci text #}
|
||||
<h2>
|
||||
{% block nadpis1a %}{% block nadpis1b %}
|
||||
Tož vitajte!
|
||||
{% endblock %}{% endblock %}
|
||||
</h2>
|
||||
<p> Uvítací text či-co.</p>
|
||||
|
||||
{# Novinky #}
|
||||
<h2>Novinky</h2>
|
||||
|
||||
{% for novinka in object_list %}
|
||||
{# pripravene div-y na stylovani#}
|
||||
<div>
|
||||
{# datum #}
|
||||
<div><b>{{novinka.datum}}</b></div>
|
||||
{# text #}
|
||||
{% autoescape off %}{{novinka.text}}{% endautoescape %}
|
||||
{# obrazek #}
|
||||
{% if novinka.obrazek %}
|
||||
<div>
|
||||
<img src='{{novinka.obrazek.url}}'
|
||||
height='
|
||||
{% if novinka.obrazek.height > 200 %} {# vyska obrazku natvrdo #}
|
||||
200
|
||||
{% else %}
|
||||
{{novinka.obrazek.height}}
|
||||
{% endif%}
|
||||
'>
|
||||
</div>
|
||||
{% endif %}
|
||||
{# autor #}
|
||||
<div>{{novinka.autor.first_name}}
|
||||
{% if novinka.autor.organizator.prezdivka%}
|
||||
„{{novinka.autor.organizator.prezdivka}}“
|
||||
{% endif %}
|
||||
{{novinka.autor.last_name}}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor%}
|
||||
{% endblock %}
|
||||
|
|
|
@ -43,11 +43,11 @@ class TitulniStranaView(generic.ListView):
|
|||
model = Novinky
|
||||
template_name='seminar/titulnistrana.html'
|
||||
pred_dvema_mesici = (date.today() - timedelta(2*365/12))
|
||||
queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, date.today()))
|
||||
queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, date.today())).filter(zverejneno=True).order_by('-datum')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
||||
return context
|
||||
#def get_context_data(self, **kwargs):
|
||||
# context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
||||
# return context
|
||||
|
||||
### Co je M&M
|
||||
|
||||
|
|
Loading…
Reference in a new issue