Is there a reason, in Model.full_clean, for clean_fields be called before clean?
In my project, it would be more reasonable if I could first do my validations to then validate clean_fields stuff, like in this situation:
class MyModel(models.Model):
status = models.IntegerField(blank=False, null=False)
def clean(self):
if not self.status:
self.status = 0
Would be any problem changing this ordering in full_clean?
Why would it be "more reasonable"? As it's name describes, clean_fields is designed to clean each field individually, whereas the purpose of clean is only to validate field interactions. For example, one field can be blank only if another field is set, etc. The clean_fields method is called first to ensure that you can actually validate these interactions; if the fields have errors in general, it's pointless to validate them in conjunction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With