Thanks for the replies. As always, reading the docs again teaches you a bit more than the first time; I now see that that initial was not what I was after.
Arnaud, I think your method is more what I was after and as you say, it does exactly what I wanted. It seems to be much simpler than overriding the __init__ method. Is that simplicity at some cost I wonder? Paul Hide On Feb 18, 12:35 am, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > On Feb 17, 7:05 pm, "paulh" <[EMAIL PROTECTED]> wrote: > > > I feel the following should work: > > class Myform(forms.Form): > > ...publ = forms.ChoiceField(label='Publisher', required=False) > > > and then in handler I should be able to set the choices dynamically > > by: > > > def meth(request): > > ...frm=Myform(initial={'publ':((1,2),(2,3),(3,4)))}) #even if the > > brackets are wrong here, they were right in the original > > That shouldn't work as initial is meant to set the value of a field. > > I had the same problem and a peek at the source told me that a > ChoiceField has a 'choices' attribute which is settable so: > > form = MyForm(...) > form.fields['publ'].choices = ((1,2),(2,3),(3,4)) > > will work, but I don't know whether it is the right thing to do (TM). > > -- > Arnaud --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---