only load search when needed
[wolnelektury.git] / apps / social / forms.py
index bbdc43c..5834ffa 100755 (executable)
@@ -14,12 +14,14 @@ class UserSetsForm(forms.Form):
     def __init__(self, book, user, *args, **kwargs):
         super(UserSetsForm, self).__init__(*args, **kwargs)
         self.fields['set_ids'] = forms.ChoiceField(
-            choices=[(tag.id, tag.name) for tag in Tag.objects.filter(category='set', user=user)],
+            choices=[(tag.id, tag.name) for tag in
+                Tag.objects.filter(category='set', user=user).iterator()],
         )
 
 
 class ObjectSetsForm(forms.Form):
-    tags = forms.CharField(label=_('Tags (comma-separated)'), required=False)
+    tags = forms.CharField(label=_('Tags (comma-separated)'), required=False,
+                           widget=forms.Textarea())
 
     def __init__(self, obj, user, *args, **kwargs):
         self._obj = obj
@@ -27,7 +29,7 @@ class ObjectSetsForm(forms.Form):
         data = kwargs.setdefault('data', {})
         if 'tags' not in data and user.is_authenticated():
             data['tags'] = ', '.join(t.name
-                for t in obj.tags.filter(category='set', user=user) if t.name)
+                for t in obj.tags.filter(category='set', user=user).iterator() if t.name)
         super(ObjectSetsForm, self).__init__(*args, **kwargs)
 
     def save(self, request):