As far as I can see the __init__ way of doing things creates a field
as opposed to a base_field. Given that this is done in the __init__
method every instance will have this field. Is there any disadvantage
in this? I suppose you could also have a base_field with the same name/
key. Looking at the django code there doesn't seem to be any real
difference between a base_field and a field that is created in the
__init__ method; or maybe I've missed something.

Paul Hide

On Feb 18, 6:21 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 2/18/07, paulh <[EMAIL PROTECTED]> wrote:
>
>
>
> > 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?
>
> yes, you must either wrap the form in a function or assin the choices
> every time you wish to work with the form. with overriding the
> __init__, it is part of the form and you don't have to think about it
> at all... depends how you want to use it...
>
>
>
>
>
> > 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
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


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

Reply via email to