The first set is required = False for fields that do not need to be set if you save as a draft. Then in your form add a field of type save_as_draft, which is logical. Now you need a method to check these fields depending on the state of the save_as_draft field (regardless of whether the user has selected this field or not). You can use this method:
def is_provided(self, field):
value = self.cleaned_data.get(field, None)
if value == None or value == '':
self._errors[field] = ErrorList([u'This field is required.'])
if field in self.cleaned_data:
del self.cleaned_data[field]
. :
def clean(self):
draft = self.cleaned_data.get('save_as_draft', False)
if not draft:
req_fields = ['field1', 'field2', 'field3']
for f in req_field:
self.is_provided(f)
return self.cleaned_data
save_as_draft , - , save_as_draft . aa self.save_as_draft Form.clean, , .
,