Opened 13 years ago
Closed 12 years ago
#17911 closed Bug (fixed)
Admin change page does not "map" None choices when they are readonly
Reported by: | Owned by: | edwtjo | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | charette.s@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | yes |
Description
The Django admin change page does not "map" None values as per the class' model field choices when the values are readonly. It shows "(None)" (this value comes from EMPTY_CHANGELIST_VALUE) instead. This is demonstrated by the attached screenshot original_helpers_incorrect_change.png. The admin select page properly maps None values based on the class' model field choices. This is demonstrated by the attached screenshot original_helpers_correct_select.png. The change page should display the same value that the select page does. See attached screenshot modified_helpers_correct_change.png for what the admin change page should look like.
This is due to a bug in contrib/admin/helpers.py. The easiest way to fix the bug is to change line 185 of helpers.py from
result_repr = EMPTY_CHANGELIST_VALUE
to
result_repr = display_for_field(value, f)
However, that leaves the if and else branches executing the same statement (kind of weird). I have attached a modified version of helpers.py where that if/elif/else has been rewritten as an if/else.
I have also attached a tarball of an application that demonstrates this bug. The username is "user" and password is "password".
This is my first ticket submission, so I hope I provided everything you need.
Attachments (6)
Change History (15)
by , 13 years ago
Attachment: | mysite.tar added |
---|
by , 13 years ago
Attachment: | original_helpers_correct_select.png added |
---|
Django admin select page with original helpers.py file (correct)
by , 13 years ago
Attachment: | original_helpers_correct_select.2.png added |
---|
Django admin change page with original helpers.py file (incorrect)
by , 13 years ago
Attachment: | modified_helpers_correct_change.png added |
---|
Django admin change page with modified helpers.py file (correct)
comment:1 by , 13 years ago
Cc: | added |
---|---|
Has patch: | unset |
Can you provide a diff against trunk of helpers.py
instead of the modified file? It's easier to review the changes this way.
by , 13 years ago
Attachment: | helpers_diff.txt added |
---|
diff of modified helpers.py file against trunk
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:5 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:8 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
The added test doesn't work on Oracle, see #19391.
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Sorry, didn't mean to reopen this one.
tarball of project that demonstrates bug