Opened 3 years ago

Closed 2 years ago

#33267 closed New feature (fixed)

Add Hyperlink to related model in admin change form.

Reported by: Thomas Güttler Owned by: Shubh Parmar
Component: contrib.admin Version: 3.2
Severity: Normal Keywords:
Cc: Phil Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Thomas Güttler)

I would like to add a hyperlink next to the select field of a ForeignKey

There is a do-it-yourself way Django Admin: Add Hyperlink to related model, but it would be nice to have declarative solution.

There is an image in the Stackoverflow question which explains it.

Would you accept a PR which implements this?

Attachments (1)

django-admin-hyperlink-to-related-model.png (32.0 KB ) - added by Thomas Güttler 3 years ago.

Download all attachments as: .zip

Change History (18)

by Thomas Güttler, 3 years ago

comment:1 by Thomas Güttler, 3 years ago

Description: modified (diff)

comment:2 by Thomas Güttler, 3 years ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 2 years ago

Component: Uncategorizedcontrib.admin

Thanks for this ticket. Can you describe your use case? Do you want to have the same mechanism as the magnifying glass button for raw_id_fields?

comment:4 by Mariusz Felisiak, 2 years ago

Resolution: needsinfo
Status: newclosed

comment:5 by Mariusz Felisiak, 2 years ago

Summary: Django Admin: Add Hyperlink to related modelAdd Hyperlink to related model in admin change form.

comment:6 by Thomas Güttler, 2 years ago

Resolution: needsinfo
Status: closednew

Sorry for the late reply. The raw_id_fields displays a hyperlink next to the raw-id. That's great. I would like to have exactly the same for non-raw-id-fields.

The magnifying glass button does something else. It opens a popup. That's not what I was looking for. I was looking for a simple hyperlink to the admin interface of the corresponding ForeignKey.

Last edited 2 years ago by Thomas Güttler (previous) (diff)

comment:7 by Carlton Gibson, 2 years ago

Triage Stage: UnreviewedAccepted

Seems similar to b79088306513d5ed76d31ac40ab3c15f858946ea #31181. I think it's worth having a look at a patch, yes. Thanks Thomas.

comment:8 by Phil, 2 years ago

Cc: Phil added

The discussed feature is present in Django==4.1.dev20211119084757 including tests. It is also present in the tag 3.2.9 and 3.2.

For what version is the patch then needed? I could do that, but it would be my first contribution to Django whatsoever.

Last edited 2 years ago by Phil (previous) (diff)

comment:9 by Shubh Parmar, 2 years ago

Owner: changed from nobody to Shubh Parmar
Status: newassigned

I will try to make a patch for this.

comment:10 by Shubh Parmar, 2 years ago

Do I have to provide a hyperlink to the related object's change page or to the related model's changelist page?

comment:12 by Jacob Walls, 2 years ago

Has patch: set

comment:13 by Mariusz Felisiak, 2 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:14 by Shubh Parmar, 2 years ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

I have made the required changes. Can someone review the PR?

comment:15 by Mariusz Felisiak, 2 years ago

Patch needs improvement: set

comment:16 by Mariusz Felisiak, 2 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:17 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 11cc2273:

Fixed #33267 -- Added link to related item to related widget wrapper in admin.

Note: See TracTickets for help on using tickets.
Back to Top