django-representatives issueshttps://git.laquadrature.net/la-quadrature-du-net/memopol/django-representatives/-/issues2018-09-07T01:58:50+02:00https://git.laquadrature.net/la-quadrature-du-net/memopol/django-representatives/-/issues/19add_representative_country_and_main_mandate is suboptimal2018-09-07T01:58:50+02:00robin Tissotadd_representative_country_and_main_mandate is suboptimal*Created by: lauxley*
So i was looking for where representative.main_mandate came from and it led me to [representatives.views.RepresentativeViewMixin.add_representative_country_and_main_mandate](https://github.com/political-memory/djan...*Created by: lauxley*
So i was looking for where representative.main_mandate came from and it led me to [representatives.views.RepresentativeViewMixin.add_representative_country_and_main_mandate](https://github.com/political-memory/django-representatives/blob/master/representatives/views.py#L30)
and i think the same could be done with:
```python
country = representative.mandates.filter(constituency__isnull=False, constituency__country__isnull=False)[0].constituency.country
main_mandate = representative.mandates.filter(end_date__gt=today, group__kind='group')[0]
```
And since it's not so time consuming any more cached properties on the model would be cool ?