def home(request):
tracks = Track.objects.all().annotate().order_by('releases__party', 'trackartist__artist__name', 'name', 'remix')
- partyCompoTracks = defaultdict(lambda: defaultdict(list))
+ partyYearCompoTracks = defaultdict(lambda: defaultdict(list))
for track in tracks:
for release in track.releases.all():
- partyCompoTracks[release.party][release.compo].append(track)
- for party, compoTracks in partyCompoTracks.iteritems():
- partyCompoTracks[party] = dict(compoTracks)
- return render_to_response('templates/home.html', {'partyTracks': dict(partyCompoTracks)})
+ partyYearCompoTracks[(release.party, release.year)][release.compo].append(track)
+ for partyYear, compoTracks in partyYearCompoTracks.iteritems():
+ partyYearCompoTracks[partyYear] = dict(compoTracks)
+ return render_to_response('templates/home.html', {'partyTracks': dict(partyYearCompoTracks)})
def track(request, trackId):
return HttpResponse('Track: %s' % trackId)
{% for party, compoTracks in partyTracks.items %}
<div>
- <h2>{{ party }}</h2>
+ <h2>{{ party.0 }} {{ party.1 }}</h2>
{% for compo, tracks in compoTracks.items %}
<h3>{{ compo }}</h3>
<ul>