Open
Description
Code of Conduct
- I agree to follow Django's Code of Conduct
Feature Description
The feature is a small change in the AdminReadonlyField
's contents
method: Instead of joining the string representation of the related objects, join the admin_url's of them, just like with the ForeignKeys (or OneToOneFields).
Problem
When a ManyToManyField is readonly in a ModelAdmin, a list of the string representations of the related objects is shown. That isn't very useful, the idea would be to have a clickable link to be able to view the related object.
Request or proposal
proposal
Additional Details
No response
Implementation Suggestions
In the AdminReadonlyField.contents
method, when the field is a many to many relationship and the value is set, the code is as follows:
if isinstance(f.remote_field, ManyToManyRel) and value is not None:
result_repr = ", ".join(map(str, value.all()))
The change would leave the code similar to this:
if isinstance(f.remote_field, ManyToManyRel) and value is not None:
result_repr = "\n".join(
map(
lambda obj: self.get_admin_url(f.remote_field, obj),
value.all(),
)
)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Idea