diff options
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 107812b..1a0679b 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -303,10 +303,17 @@ class MarkerAdminFormBase(forms.ModelForm): if (len(choices) == 1): self.fields['categories'].widget = forms.MultipleHiddenInput() choices = list(self.fields['categories'].choices) - self.fields['categories'].label = u"{} / {}".format( - choices[0][0], choices[0][1][0][1]) - self.fields['categories'].initial = \ - [self.fields['categories'].choices[0][1][0][0]] + if type(choices[0][1]) in (list, tuple): + # hierarchical choices + self.fields['categories'].label = u"{} / {}".format( + choices[0][0], choices[0][1][0][1]) + self.fields['categories'].initial = \ + [self.fields['categories'].choices[0][1][0][0]] + else: + self.fields['categories'].label = u"{}".format( + choices[0][1]) + self.fields['categories'].initial = \ + [self.fields['categories'].choices[0][0]] if not settings.CHIMERE_SEARCH_ENGINE and 'keywords' in self.fields: self.fields.pop('keywords') if not settings.CHIMERE_DAYS_BEFORE_EVENT: |