Monday, December 21, 2015

Re: Question re django.forms.models.BaseModelFormSet.save_existing_objects()

Hi Mike, see if the documentation at the bottom of https://docs.djangoproject.com/en/stable/topics/forms/formsets/#django.forms.formsets.BaseFormSet.can_delete helps.

On Monday, December 21, 2015 at 4:00:36 AM UTC-5, James Schneider wrote:


> That is true. However, if commit was False that object wouldn't be deleted but it would still appear in the self.deleted_objects list. My concern - or more accurately lack of understanding - is that the object would remain in existence AND appear in the deleted list. This was precisely what happened in my project and which I was trying to debug.
>

Why would you expect anything to be changed in the database when commit=False?

My interpretation is that self.deleted_items is referring to the items that were selected in the form[set] for deletion, and wouldn't refer to the state of the items per the DB, given that 'self' is a Form/Formset in this case. I totally understand the confusion, though.

I would suspect that you either need a super() call somewhere, or take care to also delete those items.

> The symptom in the Admin was a checked box for deleting a child record which stubbornly stayed there despite the Admin reporting a successful save.
>
> Mike
>

Yeah, been there on my own forms from time to time.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8747c012-8398-44b8-b90c-ccbfcd020491%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment