Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: prevent newly added (child) instances from being deleted soon after. #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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