You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
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 do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
I believe ModelForm calls your model's self.clean so if you use it, or use the admin which uses it, you'll need to make sure that clean is idempotent since it'll get called at least twice in that case.
Mike Dewhirst
unread,
Apr 5, 2021, 8:35:31 PM4/5/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Thank you Ryan. I'm relatively sure that I only raise exceptions in clean() everywhere. But I will double-check to be sure to be sure.