Thanks.Malcolm After using
self.fields['condition'].widget=forms.CheckboxSelectMultiple() instead of self.fields['condition'].widget=forms.CheckboxSelectMultiple No error shows, but nothing shows about field condition on the form. I am totally new to django, could you please tell me more? Thanks. Joe On 4月6日, 上午12时34分, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2008-04-05 at 07:32 -0700, Iamnewbie wrote: > > I want to use CheckboxSelectMultiple (checkbox) under modelform > > instead of default ModelMultipleChoiceField settings. > > > my codes are as follows: > > > class Form(ModelForm): > > > def __init__(self, *args, **kwargs): > > > super(Form, self).__init__(*args, **kwargs) > > > self.fields['condition'].widget=forms.CheckboxSelectMultiple > > > class Meta: > > model=Post > > fields=('post_type', 'title', 'body', 'condition') > > > I got the error like: > > > Exception Type: AttributeError > > Exception Value: type object 'CheckboxSelectMultiple' has no > > attribute 'attrs' > > > I am total lost on this problem. anyone may help me out? Thanks. > > The "widget" attribute will be an instance, not a type, once > newforms.fields.Field.__init__ has finished running. So you probably > should be assigning CheckboxSelectMultiple() -- an instance, rather than > than the class object. > > Regards, > Malcolm > > -- > The sooner you fall behind, the more time you'll have to catch > up.http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---