#13004 closed (fixed)
The new get_readonly_fields() method of the ModelAdmin breaks with many to many fields
Reported by: | hejsan | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.2-beta |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This breaks if a ManyToMany field is specified as readonly.
This is because the contents() function that is called in the fieldset.html template tries to display the value of the field but gets a ValueError if it is a ManyToManyField because they can't be used: "[Model name] instance needs to have a primary key value before a many-to-many relationship can be used"
Just need to add ValueError to the catch as seen in the patch I attached, called catch_value_error.diff.
Hope it gets merged before beta 2.
Attachments (2)
Change History (6)
by , 15 years ago
Attachment: | catch_value_error.diff added |
---|
comment:1 by , 15 years ago
Component: | Uncategorized → Contrib apps |
---|---|
Has patch: | set |
Version: | 1.1 → 1.2-beta |
comment:2 by , 15 years ago
Component: | Contrib apps → django.contrib.admin |
---|---|
milestone: | → 1.2 |
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | catch_error_with_test-12818.diff added |
---|
Added a basic regression test along with the orginal patch.
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Very simple fix, just catch one more Exception