Opened 11 years ago
Closed 11 years ago
#24089 closed Cleanup/optimization (fixed)
Misleading error raised during system check related to ModelAdmin
| Reported by: | okrutny | Owned by: | arcturusannamalai |
|---|---|---|---|
| Component: | contrib.admin | Version: | 1.7 |
| 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
When comma is forgoten when defining fieldsets on ModelAdmin, wrong error is raised:
ERRORS:
<class 'fund_profiles.admin.OrganizationAdmin'>: (admin.E012) There are duplicate field(s) in 'fieldsets[0][1]'.
Code to reproduce:
class OrganizationAdmin(admin.ModelAdmin):
list_display = ('name','email', 'accepted_ads','accepted_rules','accepted_handling','date_created','date_modified')
list_filter = ('verified','accepted_ads',)
fieldsets = (
(_('administration'),
{
'fields': ('removed')
}),
)
Adding comma to tuple after 'removed' fixes issue.
Change History (12)
follow-up: 4 comment:1 by , 11 years ago
| Easy pickings: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 years ago
| Has patch: | set |
|---|
comment:4 by , 11 years ago
Replying to timgraham:
Looking at the
_check_fields()method incontrib/admin/checks.py, it looks like we fail to check if the nested fields inside a fieldset are a list or tuple. We can likely reuse the existing'admin.E008'code.
Can you please review my change, Tim?
follow-up: 6 comment:5 by , 11 years ago
| Needs tests: | set |
|---|
Please add a test case, check your against using our patch review checklist, and then create a pull request.
comment:7 by , 11 years ago
| Needs tests: | unset |
|---|---|
| Patch needs improvement: | set |
comment:8 by , 11 years ago
I added a test, https://github.com/django/django/pull/3876/commits and sent a pull request.
comment:9 by , 11 years ago
| Patch needs improvement: | unset |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
| Triage Stage: | Accepted → Ready for checkin |
comment:10 by , 11 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → new |
| Triage Stage: | Ready for checkin → Accepted |
Ticket is only closed when the fix is committed. And Ready for checkin should never be set by the patch author, but by a reviewer.
comment:11 by , 11 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:12 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Looking at the
_check_fields()method incontrib/admin/checks.py, it looks like we fail to check if the nested fields inside a fieldset are a list or tuple. We can likely reuse the existing'admin.E008'code.