diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 17:29:24 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-05-26 17:29:24 +0200 |
commit | 22c012d11c996019ec04e2e7559a2747126b95ad (patch) | |
tree | 81a33f5611f94aad6a85fc436a81ba256cb3bde0 /chimere/forms.py | |
parent | 1af69d67f354b62cafdd49b9b4d4453c6b5354b1 (diff) | |
download | Chimère-22c012d11c996019ec04e2e7559a2747126b95ad.tar.bz2 Chimère-22c012d11c996019ec04e2e7559a2747126b95ad.zip |
Fix edit form when there is only one category
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 74b7aa0..107812b 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -297,10 +297,12 @@ class MarkerAdminFormBase(forms.ModelForm): elif hasattr(self, 'categories_choices'): self.fields['categories'].choices = self.categories_choices # auto select if there is only one category + choices = list(self.fields['categories'].choices) + self.fields['categories'].choices = choices self.fields['categories'].label = "" - if (len(self.fields['categories'].choices) == 1): + if (len(choices) == 1): self.fields['categories'].widget = forms.MultipleHiddenInput() - choices = self.fields['categories'].choices + choices = list(self.fields['categories'].choices) self.fields['categories'].label = u"{} / {}".format( choices[0][0], choices[0][1][0][1]) self.fields['categories'].initial = \ |