The BaseForm.__init__ sets self.fields to self.base_fields.copy()
before your __init__ is run.  The correct way to change the label is:

class TestForm(forms.Form):
    somefield = forms.IntegerField(label='foo')

On Jan 30, 1:06 pm, Kirk Strauser <[EMAIL PROTECTED]> wrote:
> I'm using a Newforms subclass, and trying to dynamically generate the labels
> for each field at runtime (long story, but it really does make sense for
> what we're doing).  Apparently I'm doing something wrong, though, because I
> always end up with the default label text and not what I'm specifying.  For
> example:
>
> class TestForm(forms.Form):
>     def __init__(self, *args, **kwargs):
>         super(ArrivalForm, self).__init__(*args, **kwargs)
>         self.base_fields['somefield'].label = 'foo'
>
>     somefield = forms.IntegerField()
>
> This doesn't have the behavior I'd expect of changing somefield's label
> from 'Somefield' to 'foo'.  Is this possible?
> --
> Kirk Strauser
>
>  signature.asc
> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to