Found a bug related with admin panel, m2m-field and model save() method
90 views
Skip to first unread message
Антон Игин
unread,
Sep 27, 2020, 3:28:13 PM9/27/20
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 developers (Contributions to Django itself)
Methods associated with m2m (clear, set) fields do not work in the save () method of the model using from the admin panel. The error did not occur when instantiation or update was initiated from other sources (wrapper, control command api)
Details (test project with instructions to reproduction) here:
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 developers (Contributions to Django itself)
I believe the behaviour you're seeing is due to the fact that the admin view first has to save the instance of the model being edited, and only then can it save the related objects and relationships. So it is a two-step thing:
Not sure if it is a bug, though. Perhaps it can be documented (if it isn't). Something like "If you are overriding MyModel.save (or using post_save signal?), be aware that the admin <does what it does>..."?