Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django forms: Changing help_text dynamically

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?

like image 298
ajc Avatar asked Jul 20 '10 03:07

ajc


1 Answers

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'
like image 117
gruszczy Avatar answered Sep 18 '22 12:09

gruszczy