Skip to content

Conversation

@amartis
Copy link

@amartis amartis commented Feb 17, 2022

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.

…n after.

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.
@amartis amartis changed the title Bug fix: prevent newly added (child) instances from being deleted soo… Bug fix: prevent newly added (child) instances from being deleted soon after. Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant