Commit e6df0ee4 authored by Nicolas Joyard's avatar Nicolas Joyard

Force a specific ordering of entries

parent 4ab9da5e
...@@ -59,8 +59,9 @@ class RepresentativeDetail(RepresentativeViewMixin, generic.DetailView): ...@@ -59,8 +59,9 @@ class RepresentativeDetail(RepresentativeViewMixin, generic.DetailView):
c['votes'] = c['object'].votes.all() c['votes'] = c['object'].votes.all()
c['mandates'] = c['object'].mandates.all() c['mandates'] = c['object'].mandates.all()
c['positions'] = c['object'].positions.filter( c['positions'] = c['object'].positions.filter(published=True) \
published=True).prefetch_related('tags') .prefetch_related('tags') \
.order_by('-datetime', 'pk')
c['position_form'] = PositionForm( c['position_form'] = PositionForm(
initial={'representative': self.object.pk}) initial={'representative': self.object.pk})
......
...@@ -20,9 +20,9 @@ class RepresentativeViewMixin(object): ...@@ -20,9 +20,9 @@ class RepresentativeViewMixin(object):
""" """
Prefetch Mandates with their Group and Constituency with Country. Prefetch Mandates with their Group and Constituency with Country.
""" """
mandates = Mandate.objects.order_by( mandates = Mandate.objects.order_by('-end_date', '-begin_date',
'-end_date').select_related('constituency__country', 'group', 'group__kind', 'group__name').select_related('group',
'group__chamber') 'group__chamber', 'constituency__country')
return queryset.prefetch_related( return queryset.prefetch_related(
models.Prefetch('mandates', queryset=mandates)) 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