On 16/11/2015 4:32 PM, Mike Dewhirst wrote:
I've been trying to figure out why I can't delete child records
displayed in the Admin. Finally tracked it down to this method in
admin.py which when commented out restores the ability to check the
Delete box and get rid of the child record on clicking Save.


Apologies. Finger trouble. What I meant was ...

def save_formset(self, request, form, formset, change):
    """ this updates the related records when they change """
    instances = formset.save(commit=False)
    for instance in instances:
        try:
            instance.modified_by = request.user
        except Exception:
            # some instances don't have modified_by
            pass
        instance.save()
    formset.save_m2m()

How can I keep this and get Delete to work in the Admin?

def save_formset(self, request, form, formset, change): """ this updates
the related records when they change """ instances =
formset.save(commit=False) for instance in instances: try:
instance.modified_by = request.user except Exception: # some instances
don't have modified_by pass instance.save() formset.save_m2m()


How can I keep this and get Delete to work in the Admin?

Thanks

Mike


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5649734C.4020800%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to