[Django]-Any danger in manually setting cleaned_data in Django?

6👍

In the case you present, your intention isn’t setting the cleaned_data, but the model data. Therefore, instead of setting cleaned_data in the save method, just set the attributes of self.instance and then save it.

About setting cleaned_data manually, I don’t think it’s necessarily wrong, it may make sense to do it in the form’s clean method for some cross-field validation, although it’s not a common case.

Leave a comment