Django required field in model form

前端 未结 6 1531
栀梦
栀梦 2020-11-29 19:44

I have a form where a couple of fields are coming out as required when I don\'t want them too. Here is the form from models.py

class CircuitForm(ModelForm):
         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 20:29

    If the model field has blank=True, then required is set to False on the form field. Otherwise, required=True

    Says so here: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

    Looks like you are doing everything right. You could check the value of self.fields['end'].required.

提交回复
热议问题