diff --git a/app/org_eleicoes/votepeloclima/candidature/filters/forms.py b/app/org_eleicoes/votepeloclima/candidature/filters/forms.py index aae778ca..b58bf058 100644 --- a/app/org_eleicoes/votepeloclima/candidature/filters/forms.py +++ b/app/org_eleicoes/votepeloclima/candidature/filters/forms.py @@ -9,7 +9,7 @@ from ..choices import Gender, Color from ..fields import CepField, ButtonCheckboxSelectMultiple, ButtonRadioSelect from ..forms import ProposeForm -from ..locations_utils import get_ufs +from ..locations_utils import get_ufs, get_choices from ..models import Candidature @@ -56,6 +56,14 @@ class Meta: class Media: js = ["https://code.jquery.com/jquery-3.5.1.min.js"] + + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + state = self.data.get("state") + if state: + self.fields["city"].choices = [("", "Selecione")] + get_choices(state) class FilterFormSidebar(RemoveRequiredMixin, forms.ModelForm):