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
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:

https://github.com/Sibiryakanton/Django_bugcase


Fran Hrženjak

unread,
Sep 27, 2020, 5:39:53 PM9/27/20
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>..."?
Reply all
Reply to author
Forward
0 new messages