Opened 7 years ago

Closed 7 years ago

#10036 closed (wontfix)

admin list_display with broken foreignkey fails

Reported by: danros Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

You have a model which includes a ForeignKey field. In one of the instances of that model, that ForeignKey points to something which has disappeared for whatever reason.

If you view the object in the admin, it correctly displays that ForeignKey mapping as '----' ie null.

If you include that ForeignKey field in list_display in admin.py, django attempts to look up that relation, fails, and throws a record not found exception.

I realise that this is fundamentally a problem with referential integrity of the database - the question is, is django's handling of that a bug?

Change History (2)

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Personally, I think all bets are off once you let your DB lose referential integrity; if anything at all continues to work, it's most likely an accident.

comment:2 Changed 7 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

Indeed; Django isn't happy with invalid references, and you shouldn't be either. A nasty error is exactly what I'd expect to see in this case.

Note: See TracTickets for help on using tickets.
Back to Top