1👍
✅
Don’t update the cleaned_data
. Call save()
with commit=False
, set the employee then save it to the db.
class EmployeeForm(forms.ModelForm):
second_form = None
def save(self):
employee = super(ShiftSubForm, self).save()
shift = self.second_form.save(commit=False)
shift.employee = employee
shift.save()
return employee
class Meta:
model = Employee
Source:stackexchange.com