Sunday, April 4, 2021

calling self.clean() before super.save()

Is it sensible to generally call self.clean() in a model's save() method
prior to calling super().save()

Until now I have been calling clean() deliberately prior to calling
save() but I have a lot of models where save() pre-processes data just
prior to calling the model's super().save(*args, **kwargs)

I feel as though it would more robust to pre-process the data, then call
self.clean() and finally make the super call.

Thanks for any advice.

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b964ddc6-39bd-2dfd-2bc7-31f0514b8d9a%40dewhirst.com.au.

No comments:

Post a Comment