Commit e6df0ee4 authored by Nicolas Joyard's avatar Nicolas Joyard
Browse files

Force a specific ordering of entries

parent 4ab9da5e
......@@ -59,8 +59,9 @@ class RepresentativeDetail(RepresentativeViewMixin, generic.DetailView):
c['votes'] = c['object'].votes.all()
c['mandates'] = c['object'].mandates.all()
c['positions'] = c['object'].positions.filter(
published=True).prefetch_related('tags')
c['positions'] = c['object'].positions.filter(published=True) \
.prefetch_related('tags') \
.order_by('-datetime', 'pk')
c['position_form'] = PositionForm(
initial={'representative': self.object.pk})
......
......@@ -20,9 +20,9 @@ class RepresentativeViewMixin(object):
"""
Prefetch Mandates with their Group and Constituency with Country.
"""
mandates = Mandate.objects.order_by(
'-end_date').select_related('constituency__country', 'group',
'group__chamber')
mandates = Mandate.objects.order_by('-end_date', '-begin_date',
'group__kind', 'group__name').select_related('group',
'group__chamber', 'constituency__country')
return queryset.prefetch_related(
models.Prefetch('mandates', queryset=mandates))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment