When I attempt to delete a user from the admin panel, I get an error screen saying IntegrityError at /admin/auth/user/
FOREIGN KEY constraint failed
, but at no point in the entire page does it mention any model, column, nor anything that could help me narrow it down. I assume it is due to my model which has a models.OneToOneField(AuthUser, on_delete = models.CASCADE)
, though I would think the on_delete should delete it, it seems to end up dangling or something because if I delete the entry in that table first, and then delete the user that one referenced, they get deleted correctly without issue.
What do I have to do to make my entries delete themselves correctly upon deleting the user?
How do I read the error page correctly to know what's causing it?
How to override the admin delete to delete from the other table first before deleting the user normally?
Where I'm deleting the user to cause the error.
Where I have to delete the entry before deleting the user in order to avoid errors.
CodePudding user response:
Well I did some last random tests before dropping the issue and ignoring it, and I happened across the fact that replacing AuthUser
with User
fixes everything.
I've got no clue where User
exists, because it is not an existing table in my database, like AuthUser
is, but for some reason with that it all works just fine, so no complaints from me.