Opened 5 years ago

Closed 5 years ago

#30980 closed Cleanup/optimization (fixed)

admin.E130 (duplicate __name__ attributes of actions) should specify which were duplicated.

Reported by: Keryn Knight Owned by: AdamDonna
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: yes UI/UX: no

Description

The fact that the __name__ is used is somewhat an implementation detail, and there's no guarantee the user has enough of an understanding of python to know what that attribute is, let alone how to fix it.

This just came up on IRC because a user had defined actions = [delete_selected] where delete_selected was a reference to their own callable, but shares the name of the base one (and by specifying the actions = they were assuming that they were wholesale replacing the actions list, where that may not be true for site-wide actions) so errored ... but they only had define a list of len(...) == 1 so how can there be a duplicate (is their thought process)?

The error message should specify those names that occur 2> (rather than just check len(...) vs len(set(...))), and ought ideally to explain where the duplicate comes from (ie: AdminSite-wide).

Related ticket about E130: #30311 (+ those it references) but is about the replacement strategy rather than the error message itself.

Change History (7)

comment:1 by Mariusz Felisiak, 5 years ago

Easy pickings: set
Summary: admin.E130 (duplicate __name__ attributes of actions) should specify which were duplicatedadmin.E130 (duplicate __name__ attributes of actions) should specify which were duplicated.
Triage Stage: UnreviewedAccepted

Agreed, we can add names of duplicated actions to this message.

comment:2 by KESHAV KUMAR, 5 years ago

Owner: changed from nobody to KESHAV KUMAR
Status: newassigned

comment:3 by KESHAV KUMAR, 5 years ago

Hey! I am new to django contribution and I want to solve this issue. I want to know that error message of duplicates should write after the error of unique name in the same function ?

comment:4 by Parth Patil, 5 years ago

Has patch: set
Needs documentation: set
Patch needs improvement: set

comment:5 by Mariusz Felisiak, 5 years ago

comment:6 by Mariusz Felisiak, 5 years ago

Needs documentation: unset
Owner: changed from KESHAV KUMAR to AdamDonna
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 8b3e714e:

Fixed #30980 -- Improved error message when checking uniqueness of admin actions' name.

Thanks Keshav Kumar for the initial patch.

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