Hi,

I try to create an admin form field using both a custom label and the
FilteredSelectMultiple widget:

from django.contrib.admin.widgets import FilteredSelectMultiple

class UserMultipleModelChoiceField(forms.ModelMultipleChoiceField):
    def label_from_instance(self, obj):
        return "%s (%s)" % (obj.get_full_name(), obj.username)

class UserProfileForm(forms.ModelForm):
        supervisors =
UserMultipleModelChoiceField(queryset=User.objects.all(),
required=False, widget=FilteredSelectMultiple)

Django complains that there are too few arguments for the field's
__init__ method, pointing to line 937 of django/forms/models.py
(Django v1.2).

TypeError at /admin/profile/userprofile/220/
__init__() takes at least 3 arguments (1 given)

If I remove the custom widget parameter:

supervisors = UserMultipleModelChoiceField(User.objects.all())

everything looks fine. What am I doing wrong here?

- Jan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to