When the Bug is happening:
This happens when the request was made as mutlipart-form.
Where the request data is not multi-layer dictionary, but instead plain HTTP multipart-form.
Cause of Bug:
The cause of the bug was the use of get_initial() to store primary keys (pk) in update_or_create_reverse_relations()
get_initial() returns whole new object when the data is not nested dictionary but multipart-form where the key looks like profile[0]message_set[0]message
And thus storing pk in that object is not persisted for delete_reverse_relations_if_need()
Solution:
Use attribute nodelete_pks to persist the data.
When the Bug is happening: This happens when the request was made as mutlipart-form. Where the request data is not multi-layer dictionary, but instead plain HTTP multipart-form.
Cause of Bug: The cause of the bug was the use of get_initial() to store primary keys (pk) in
update_or_create_reverse_relations()
get_initial() returns whole new object when the data is not nested dictionary but multipart-form where the key looks likeprofile[0]message_set[0]message
And thus storing pk in that object is not persisted fordelete_reverse_relations_if_need()
Solution: Use attribute
nodelete_pks
to persist the data.