views:

31

answers:

1

Is this even possible?

So let's say that I have two forms, one inherits from the other because they have similar fields with the same validation. But the only difference is they have different help text. How could I have two different help text on these forms?

A: 

Try this:

class A(Form):
  f = CharField(help_text='sth')


class B(A):

    def __init__(self, *args, **kwargs):
        super(B, self).__init__(*args, **kwargs)
        self.fields['f'].help_text = 'changed'
gruszczy
It's preferable to call `super(B, self).__init__(*args, **kwargs)` instead of `A.__init__(self, *args, **kwargs)`, but yes, that will work.
Aram Dulyan
I've fixed this. I never know, which I should use.
gruszczy