|
#17988: BaseModelFormset.save doesn't honor commit=False when deleting objects.
-------------------------------+-------------------- Reporter: rem | Owner: nobody Type: Uncategorized | Status: new Component: Forms | Version: 1.3 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 1 Easy pickings: 1 | UI/UX: 0 -------------------------------+-------------------- When saving a `ModelFormSet` with some object(s) marked for deletion, calling `formset.save(commit=False)` still deletes the objects, which would then cause an obscure `ValidationEror` with `invalid_choice` when `formset.save()` is called again. The attached patches are against trunk, but this exists as of 1.3, if not earlier. -- Ticket URL: <https://code.djangoproject.com/ticket/17988> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en. |
|
#17988: BaseModelFormset.save doesn't honor commit=False when deleting objects.
-------------------------------+------------------------------------ Reporter: rem | Owner: nobody Type: Uncategorized | Status: new Component: Forms | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------+------------------------------------ Changes (by Fandekasp): * cc: lemaire.adrien@… (added) * needs_better_patch: => 0 * needs_docs: => 0 * needs_tests: => 0 * stage: Unreviewed => Accepted Comment: LGTM -- Ticket URL: <https://code.djangoproject.com/ticket/17988#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en. |
|
In reply to this post by Django
#17988: BaseModelFormset.save doesn't honor commit=False when deleting objects.
-------------------------------+------------------------------------ Reporter: rem | Owner: nobody Type: Uncategorized | Status: new Component: Forms | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 1 | UI/UX: 0 -------------------------------+------------------------------------ Changes (by akaariai): * cc: akaariai (added) * needs_better_patch: 0 => 1 Comment: Hmmh, I think this causes problems for this common use-case: {{{ instances = formset.save(commit=False) for instance in instances: instance.user = user instance.save() }}} Currently I think things would work as follows: "deleted" instance are deleted by the formset.save(commit=False) call. The to-be-saved instances are returned, but not yet saved. After the change the deleted objects would still remain in the database after the snippet is run. Hence, the current patch is backwards incompatible. I think a better fix would be to somehow remember that .save(commit=False) has already deleted the instances when calling the .save() again. This would get rid of the error, yet fix the problem. -- Ticket URL: <https://code.djangoproject.com/ticket/17988#comment:2> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en. |
|
In reply to this post by Django
#17988: BaseModelFormset.save doesn't honor commit=False when deleting objects.
------------------------+------------------------------------- Reporter: rem | Owner: tuxcanfly Type: Bug | Status: assigned Component: Forms | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 ------------------------+------------------------------------- Changes (by tuxcanfly): * owner: nobody => tuxcanfly * needs_better_patch: 1 => 0 * status: new => assigned * type: Uncategorized => Bug * cc: tuxcanfly (added) Comment: Applied the patches and updated them according to akaariai's suggestions. Pushed to my branch on github at: https://github.com/tuxcanfly/django/tree/ticket_17988 Needs review. -- Ticket URL: <https://code.djangoproject.com/ticket/17988#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [hidden email]. To unsubscribe from this group, send email to [hidden email]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en. |
| Powered by Nabble | Edit this page |
