1๐
cleaned_data
is the dictionary of data after all validation in every field in that form. Now you can decide whether to rely on it or not(preferably you should).So as a pseudocode we could saycleaned_data + errors
will be all fields.commit
is used to decide whether it should commit to db(write). From the above code, to add a related model object likeprofile
, the original object(User
) has to be created first.Thats why it make force commit.- To add a related object on object creation, there are multiple ways like
post_save
signals, override modelsave
, override formsave
etc.So you are using one of good approach, I would say.
๐คitzMEonTV
Source:stackexchange.com