Hallöchen! Jim Myers writes:
> [...] > > I have a Form with a ChoiceField where the choices are established > by reading them from the database. Then I try to initialize the > initial selected choice so it will be "selected" in the HTML. But > nothing I tried works. [...] I'm not sure because your snippet seems to be slightly crippled, but I was annoyed by browser behaviour in this case: Reload didn't update the ChoiceField, but I had to visit the browser's URL line with the cursor and hit Return. > 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)) See Python's built-in "enumerate". 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 -~----------~----~----~----~------~----~------~--~---