Hallöchen!

On a second look, I see other things that may be problematic.

Jim Myers writes:

> [...]
>
> class PhoneForm(forms.Form):
>     telephoneType = forms.ChoiceField(required=True,choices=[])
>     def __init__(self, *args, **kwargs):
>         super(forms.Form, self).__init__(*args, **kwargs)
>         choices = TelephoneType.objects.all()
>         tt = []
>         i = 0
>         for c in choices:
>             i = i + 1
>             tt.append((i,c.telephone_type))
>         self.fields['telephoneType'].choices = tt
>         self.fields['telephoneType'].initial = 2

I don't know whether you can set initial values after the "super"
call.  I put them before by injecting them into the kwargs
dictionary.  Of course, you must first extract any already-existing
"initial" item in it.

>

Is here a "def" line missing?

>     PhoneFormSet = formset_factory(PhoneForm, extra=1, can_delete=True)
>     phones = get_phones(person_id)
>     phoneData = []
>     for t in phones:
>         tt = TelephoneType.objects.get(telephone_type=t.telephone_type)
>         do = tt.display_order
>         phoneData.append({'telephoneType': do})
>
>     phone_formset = PhoneFormSet(initial=phoneData)
>     logging.debug(str(phone_formset))
>     return phone_formset

You must not pass a list to the "initial" keyword argument.  It
needs a dictionay.  A ChoiceField can have only one initial value
after all (in contrast to a MultipleChoiceField).

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
                                  or http://bronger-jmp.appspot.com


--~--~---------~--~----~------------~-------~--~----~
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 
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