The new get_readonly_fields() method of the ModelAdmin breaks with many to many fields
|Reported by:||hejsan||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (6)
Changed 4 years ago by hejsan
comment:1 Changed 4 years ago by hejsan
- Component changed from Uncategorized to Contrib apps
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Version changed from 1.1 to 1.2-beta
comment:2 Changed 4 years ago by russellm
- Component changed from Contrib apps to django.contrib.admin
- milestone set to 1.2
- Triage Stage changed from Unreviewed to Accepted