Django: Make certain fields in a ModelForm required=False

后端 未结 5 1954
无人共我
无人共我 2021-02-02 06:08

How do I make certain fields in a ModelForm required=False?

If I have:

class ThatForm(ModelForm):
  class Meta:
    widgets = {\"text\": Textarea(require         


        
5条回答
  •  爱一瞬间的悲伤
    2021-02-02 06:57

    You could try this:

    class ThatForm(ModelForm):
      class Meta:
        requireds = 
        {
           'text':False,
        }
    

    requireds must be under Meta.

提交回复
热议问题