Django modelform NOT required field

后端 未结 7 1146
一整个雨季
一整个雨季 2021-01-30 01:54

I have a form like this:

class My_Form(ModelForm):
    class Meta:
        model = My_Class
        fields = (\'first_name\', \'last_name\' , \'address\')
         


        
7条回答
  •  太阳男子
    2021-01-30 02:31

    The above answers are correct; nevertheless due note that setting null=True on a ManyToManyField has no effect at the database level and will raise the following warning when migrating:

    (fields.W340) null has no effect on ManyToManyField.

    A good answer to this is explained in this other thread.

提交回复
热议问题