Opened 14 years ago

Closed 13 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)

01.diff (2.7 KB ) - added by Chris Lamb 14 years ago.
ticket15669.diff (4.0 KB ) - added by Jure Cuhalev <gandalf@…> 14 years ago.
Updated patch with tests
ticket15669_2.diff (8.9 KB ) - added by Jure Cuhalev <gandalf@…> 14 years ago.
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.

Download all attachments as: .zip

Change History (12)

by Chris Lamb, 14 years ago

Attachment: 01.diff added

comment:1 by Julien Phalip, 14 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Could you provide some tests for this?

comment:2 by Luke Plant, 14 years ago

Type: New feature

comment:3 by Luke Plant, 14 years ago

Severity: Normal

comment:4 by Julien Phalip, 14 years ago

UI/UX: set

comment:5 by Jure Cuhalev <gandalf@…>, 14 years ago

Easy pickings: unset
Owner: changed from nobody to anonymous
Status: newassigned

comment:6 by Jure Cuhalev <gandalf@…>, 14 years ago

Owner: changed from anonymous to gandalfar
Status: assignednew

by Jure Cuhalev <gandalf@…>, 14 years ago

Attachment: ticket15669.diff added

Updated patch with tests

comment:7 by Kristian Klette, 14 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Alex Gaynor, 14 years ago

You can simplify to unicode(model._meta) which makes this a bit shorter.

by Jure Cuhalev <gandalf@…>, 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.

comment:9 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16462]:

Fixed #15669 -- Included app label in admin validation messages. Thanks, lamby and Jure Cuhalev.

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