Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object matching query does not exist when try to delete object

When I try to delete Comany (model) with related objects, I get strange exception: Object matching query does not exist when try to delete object

company =  Company.objects.get(id=request.GET.get('id'))
company.delete() //on this line

Could you please explain what could be issues, as django should delete related objects by default?

like image 690
Oleg Avatar asked Mar 04 '14 13:03

Oleg


1 Answers

This error was because of using post_delete signal, it tried to access data that was already deleted and unaccessible.

like image 71
Oleg Avatar answered Nov 15 '22 01:11

Oleg