diff --git a/memopol/views/representative_detail.py b/memopol/views/representative_detail.py index 7b484e348a785357393b8b3cfba9ed483c4497e8..4ced478ae37c826d4f50443c2e1e8b6734b633c1 100644 --- a/memopol/views/representative_detail.py +++ b/memopol/views/representative_detail.py @@ -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}) diff --git a/memopol/views/representative_mixin.py b/memopol/views/representative_mixin.py index 55547c693bf6d56371f15e16888109a7d50aa72d..42fe1135aa3ff5c59ed2a139714743c3b53cc11f 100644 --- a/memopol/views/representative_mixin.py +++ b/memopol/views/representative_mixin.py @@ -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))