Re: Trying to dynamically generate labels in newforms

2008-01-31 Thread Kirk Strauser
> Use fields instead of base_fields : > > 1. > class TestForm(forms.Form): > def __init__(self, *args, **kwargs): > super(ArrivalForm, self).__init__(*args, **kwargs) > self.fields['somefield'].label = 'foo' > > somefield = forms.IntegerField() Yells "d'oh!" and slaps foreh

Re: Trying to dynamically generate labels in newforms

2008-01-31 Thread Pigletto
> Yes, but I won't know the value of 'foo' until runtime. There's no > other way to set it? I don't want to hardcode a bunch of entries like > "self.somefield = whatever" in __init__, either, because I'm trying to > consolidate a bunch of ad-hoc code into a single inheritable class. Use fields i

Re: Trying to dynamically generate labels in newforms

2008-01-30 Thread Michael Elsdörfer
> There's no other way to set it? Just set the labels *before* calling super(). Michael --~--~-~--~~~---~--~~ 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@googl

Re: Trying to dynamically generate labels in newforms

2008-01-30 Thread Kirk Strauser
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jan 30, 2008, at 3:22 PM, Paul wrote: > > 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.IntegerFiel

Re: Trying to dynamically generate labels in newforms

2008-01-30 Thread Paul
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