2007/2/2, Honza Král <[EMAIL PROTECTED]>:
> On 2/2/07, aaloy <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I'm trying use form inheritance to render the form, but it seems
> > Django just renders the child fields and not the parent ones. Is this
> > a feature or a bug?
> >
> >
> > class Pare(forms.Form):
> >    ...:     referencia = forms.CharField(max_length=12)
> >
> > class Fill(Pare):
> >    ...:     test = forms.IntegerField()
>
> if you rewrite this like
>
> class Pare(forms.Form):
>             def __init__( self, *args, **kwargs ):
>                   forms.Form( self, *args, **kwargs )
>                   self.fields['referencia'] = forms.CharField(max_length=12)
>
> class Fill(Pare):
>    ...:     test = forms.IntegerField()
>
> it should work....
> its just a workaround, but it works for me
>

Thank you for answer.
Finally what worked for me was

class Pare(forms.Form):
             def __init__( self, *args, **kwargs ):
                   forms.Form( self, *args, **kwargs )
                   self.fields['referencia'] = forms.CharField(max_length=12)

class Fill(Pare):
...

So, I do not use class atributes anymore to define the forms. The
classes are a little bit more verbose, but the inheritance is quite
clear.

-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

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