Object matching query does not exist when try to delete object
Asked Answered
D

1

5

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?

Dynamic answered 4/3, 2014 at 13:54 Comment(5)
are you sure your object with this id exist?View
Yes, error happens when I try to delete it.Dynamic
method get retuns object and not exception happensDynamic
This error was because of using post_delete signal, it tried to access data that was already deleted and unaccessible.Dynamic
Did you find any solution?Conglutinate
D
7

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

Dynamic answered 5/3, 2014 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.