save_formset in Admin prevents deleting children

17 views
Skip to first unread message

Mike Dewhirst

unread,
Nov 16, 2015, 12:33:16 AM11/16/15
to django...@googlegroups.com
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.

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

Mike Dewhirst

unread,
Nov 16, 2015, 1:11:05 AM11/16/15
to django...@googlegroups.com
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 ...
Reply all
Reply to author
Forward
0 new messages