Browse Source

Drobná oprava titulní strany

remotes/origin/vysl deploy-prod-2015-09-08-20-13-xlfd
Matěj Kocián 9 years ago
parent
commit
5543e368d2
  1. 8
      seminar/templates/seminar/novinky.html
  2. 5
      seminar/templates/seminar/titulnistrana.html
  3. 10
      seminar/views.py

8
seminar/templates/seminar/novinky.html

@ -1,13 +1,9 @@
{% extends 'titulnistrana.html'}
{% block body %}
{% for novinka in novinky %}
{% if novinka.datum > pred_2_mesici and novinka.zverejneno %}
{% for novinka in object_list %}
<p>
Tady bude novinka.
{{ novinka.text }}
</p>
<img src='{{ novinka.obrazek }}'
{% endif %}
<img src='{{ novinka.obrazek.url }}'
{% endfor%}
{% endblock %}

5
seminar/templates/seminar/titulnistrana.html

@ -1,8 +1,7 @@
Trala!
{% extends 'base.html' %}
HU!
{% block novinky %}
{% block content %}
Tady bude nadpis pro novinky.
{% include 'novinky.html' %}
{% include 'seminar/novinky.html' %}
{% endblock %}

10
seminar/views.py

@ -41,17 +41,11 @@ def TemataView(request):
class TitulniStranaView(generic.ListView):
model = Novinky
template_name='seminar/titulnistrana.html'
pred_dvema_mesici = (datetime.date.today() - datetime.timedelta(2*365/12))
queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, datetime.date.today()))
def get_context_data(self, **kwargs):
context = super(TitulniStranaView, self).get_context_data(**kwargs)
context['pred_2_mesici'] = (datetime.date.today() - datetime.timedelta(2*365/12)).isoformat()
#ulozi datum pred dvema mesici
#elegantneji mozne pomoci dateutil:
'''
from dateutil.relativedelta import relativedelta
date.today() + relativedelta(month=-2)
'''
return context
### Co je M&M

Loading…
Cancel
Save