Django Forms: dynamically changing help_text

Is it possible?

So, let's say that I have two forms, one is inherited from the other, because they have the same fields with the same validation. But the only difference is that they have a different help text. How can I have two different help texts about these forms?

+5
source share
1 answer

Try the following:

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'
+7
source

All Articles