X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8559c95597de98e8f6c580e97224ed3ecc9dc5c0..8c0d2b20aee2edeb9bd8639ee7fb1887359e9797:/newtagging/admin.py

diff --git a/newtagging/admin.py b/newtagging/admin.py
index 2ecc84d87..956d2cf9b 100644
--- a/newtagging/admin.py
+++ b/newtagging/admin.py
@@ -38,12 +38,12 @@ class TaggableModelForm(forms.ModelForm):
     tags = forms.MultipleChoiceField(label=_('tags').capitalize(), required=True, widget=FilteredSelectMultiple(_('tags'), False))
 
     def __init__(self, *args, **kwargs):
-        self.tags.choices = [(tag.id, tag.name) for tag in self.tag_model.objects.all()]
         if 'instance' in kwargs:
             if 'initial' not in kwargs:
                 kwargs['initial'] = {}
             kwargs['initial']['tags'] = [tag.id for tag in self.tag_model.objects.get_for_object(kwargs['instance'])]
         super(TaggableModelForm, self).__init__(*args, **kwargs)
+        self.fields['tags'].choices = [(tag.id, tag.name) for tag in self.tag_model.objects.all()]
     
     def save(self, commit):
         obj = super(TaggableModelForm, self).save()