Isn't it necessary to initialize the super class with
super(RecoverForm, self).__init__(*args, **kwargs)
When I did so i got an illegal keyword argument!
On Jun 9, 1:55 pm, Adi <[EMAIL PROTECTED]> wrote:
> Another option would be to create a __init__ (self,choices=()) method
> on form
> Then in the method, assign
> self.fields['items'].choices = choices
>
> and when you instantiate a form, you can specify the choices
> choices = [('1', '1'), ('2', '2')]
> form=RecoverForm(choices)
>
> -Adi
>
> On Jun 9, 12:43 pm, puff <[EMAIL PROTECTED]> wrote:
>
> > I needed to create a dynamically initialized MultipleChoiceField.
> > Unfortunately, the Django docs when talking about initialize didn't go
> > into how to deal with MultipleChoiceField. A bit of scratching around
> > didn't show a real solution although Getting dynamic model choices in
> > newforms (http://www.djangosnippets.org/snippets/26/) is useful. I
> > did find a ticket (#5033: Dynamic initial values for
> > MultipleChoiceFields in newforms) that was apparently closed for
> > rather poor reasons. Finally, I stumbled on this solution and am
> > posting it here in the hope that others can find it.
>
> > In the form:
>
> > class RecoveryForm( forms.Form ):
> > items = forms.MultipleChoiceField( choices = (), required =
> > False )
>
> > When it comes time to use it:
> > choices = [('1', '1'), ('2', '2')]
> > form = RecoveryForm( )
> > form.fields[ 'items' ].choices = choices
>
> > Problem solved.
>
> > That said, I'm new to Django and VERY new to newforms so there may
> > well be a better way.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---