On 22/12/2015 4:22 AM, Tim Graham wrote:
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.

Yes it does. Thank you Tim.

"If you call formset.save(commit=False), objects will not be deleted automatically. You’ll need to call delete() on each of the formset.deleted_objects to actually delete them:"

I now understand the why of it. I'll see if I can do that in the Admin after reimplementing my routine to update obj.modified_by with request.user which - somehow - was causing commit to become False.

Many thanks

Mike


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+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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
<https://groups.google.com/d/msgid/django-users/8747c012-8398-44b8-b90c-ccbfcd020491%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscr...@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/567887C7.6070903%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to