- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
#-----------view:
def catalog(request):
subcatalog_list = SubCatalog.objects.all().order_by('index')
objects_list = Object.objects.all().order_by('subcatalog')
t = loader.get_template('catalog.html')
c = RequestContext(request, {
'subcatalog_list': subcatalog_list,
'objects_list': objects_list,
})
return HttpResponse(t.render(c))
#-----------template:
{% if subcatalog_list %}
{% for subcatalog in subcatalog_list %}
<div class="section_name clear">{{ subcatalog.name }}</div>
<div class="clear"></div>
{% if objects_list %}
{% for obj in objects_list %}
{% if obj.subcatalog.id == subcatalog.id %}
<div class="section">
<a class="clear" href="{{ obj.link }}/">{{ obj.name }}</a>
{% if obj.description %}
<div class="description">{{ obj.description|safe }}</div>
{% endif %}
{% if forloop.counter0|divisibleby:3 %}
{% endif %}
{% endif %}
{% endfor %}
{% else %}
<h2>No objects available.</h2>
{% endif %}
{% endfor %}
{% else %}
<h1>No subcatalogs available.</h1>
{% endif %}
#-------И еще печенька напоследок:
<a onclick="window.location = '/create/' + {{ subcatalog.id }} + '/'"></a>
alexeypav 28.08.2011 18:01 # +2
Lure Of Chaos 28.08.2011 18:37 # 0
alexeypav 28.08.2011 19:07 # 0
alexeypav 28.08.2011 19:14 # 0
Fai 29.08.2011 14:30 # +2
>> divisibleby:3
>> :3
guest 30.08.2011 19:03 # 0
alexeypav 30.08.2011 19:53 # 0