Opened 14 years ago
Closed 14 years ago
#15669 closed New feature (fixed)
Include app label in admin validation messages
Reported by: | Chris Lamb | Owned by: | gandalfar |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
It is possible to have duplicate model names across your project (which is a good thing). However, it currently results in some ambiguous error messages when validating admin classes.
For example:
'MembershipAdmin.raw_id_fields' refers to field 'user_id' that is missing from model 'Membership'.
... does that refer to my Membership class in my "foo" app or my "bar" app?
The attached patch includes the app label in the error messages. For example:
'MembershipAdmin.raw_id_fields' refers to field 'user_id' that is missing from model 'bar.Membership'.
Attachments (3)
Change History (12)
by , 14 years ago
comment:1 by , 14 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Type: | → New feature |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|
comment:4 by , 14 years ago
UI/UX: | set |
---|
comment:5 by , 14 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:6 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:7 by , 14 years ago
Needs tests: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:8 by , 14 years ago
You can simplify to unicode(model._meta)
which makes this a bit shorter.
by , 14 years ago
Attachment: | ticket15669_2.diff added |
---|
Updated patch so that modeladmin tests also pass. I also tried approach suggested by Alex and abandoned it because unicode() repr of model lowercases the model, making it harder to grep for errors.
Could you provide some tests for this?