Change a Django form field to a hidden field

后端 未结 7 2099
故里飘歌
故里飘歌 2020-12-22 20:21

I have a Django form with a RegexField, which is very similar to a normal text input field.

In my view, under certain conditions I want to hide it from

7条回答
  •  执笔经年
    2020-12-22 21:01

    an option that worked for me, define the field in the original form as:

    forms.CharField(widget = forms.HiddenInput(), required = False)
    

    then when you override it in the new Class it will keep it's place.

提交回复
热议问题