Opened 18 years ago
Closed 18 years ago
#2111 closed defect (wontfix)
Admin site can't deal with broken ForeignKeys
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | admin, foreignkey |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm using Django's admin site to interface to an existing database that does has some broken ForeignKey references. Instead of the admin site allowing me to edit and correct these records, I can't even browse them. When the admin interface should display the "Select [model] to change" menu I get a Django error page with the exception "DoesNotExist: [model] matching query does not exist."
Change History (4)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
Unfortunately, the version of MySQL I'm stuck on doesn't enforce FKs. Some folks seem not to mind breaking FK relationships, and the admin interface is going to be the only way users have of correcting or deleting broken data.
comment:3 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Trust MySQL to be difficult :) Is there any way that this can be handled gracefully?
comment:4 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I think this is outside the scope of the admin interface. Repairing database integrity is a bit database-specific and something that has to be done at another level, usually with special tools. The admin interface assumes the persistent store is going to be well-behaved underneath it and adding special checks in for all the (very rare) cases where that might not happen will just complicate the code.
Normally, the database protects its foreign key references when you have declared them as such. So, this is not a common case. (How the heck did this happen, anyway?)