Opened 15 years ago

Closed 8 years ago

#7923 closed New feature (fixed)

Add links when using raw_id_fields in admin

Reported by: Julian Bez Owned by: Hugo Osvaldo Barrera
Component: contrib.admin Version: dev
Severity: Normal Keywords: admin raw_id_fields
Cc: bthomas@…, hugo@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using raw_id_fields in the admin application you get a field with the id and a link for looking up an id.

Already 'selected' objects are written next to the field for your information, but are not linked.

The patch improves that. You can browse through the objects now.

Attachments (6)

admin-rawid-link.diff (788 bytes) - added by Julian Bez 15 years ago.
patchtest.diff (1.3 KB) - added by Julian Bez 15 years ago.
ticket7923.patch (2.4 KB) - added by mrts 14 years ago.
Patch with test.
ticket7923-2.patch (4.4 KB) - added by mrts 14 years ago.
Fix more tests.
ticket7923-3.patch (4.5 KB) - added by mrts 14 years ago.
Fix a copy-paste from test output that hardcoded admin media prefix.
0001-Add-links-when-using-raw_id_fields-in-admin.patch (3.6 KB) - added by Hugo Osvaldo Barrera 8 years ago.
Patch updated to apply on current master

Download all attachments as: .zip

Change History (29)

Changed 15 years ago by Julian Bez

Attachment: admin-rawid-link.diff added

comment:1 Changed 15 years ago by Brian Rosner

milestone: 1.0 beta

comment:2 Changed 15 years ago by Eric Holscher

milestone: post-1.0
Triage Stage: UnreviewedDesign decision needed

comment:3 Changed 15 years ago by Bob Thomas

Cc: bthomas@… added

Changed 15 years ago by Julian Bez

Attachment: patchtest.diff added

comment:4 Changed 15 years ago by Adrian Holovaty

Are the linked objects guaranteed to have an admin page? Looks like this patch assumes that they have one.

comment:5 Changed 15 years ago by Julian Bez

Status: newassigned

I think I followed the behavior of the magnifying glass. That is always there and results in a 404 if the object does not have an admin page. This should then be fixed, too.

comment:6 Changed 15 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:7 Changed 14 years ago by Thomas Güttler

Cc: hv@… added

comment:8 Changed 14 years ago by mrts

I've updated the code to recent trunk at http://github.com/mrts/django/tree/ticket7923 . One thing that needs to be resolved is whether the link should open in a pop-up. I personally prefer the current behaviour, but a pop-up would be more consistent with how the magnifying glass and + works.

Changed 14 years ago by mrts

Attachment: ticket7923.patch added

Patch with test.

comment:9 Changed 14 years ago by Russell Keith-Magee

milestone: 1.2
Triage Stage: Design decision neededAccepted

Changed 14 years ago by mrts

Attachment: ticket7923-2.patch added

Fix more tests.

Changed 14 years ago by mrts

Attachment: ticket7923-3.patch added

Fix a copy-paste from test output that hardcoded admin media prefix.

comment:10 Changed 14 years ago by mrts

The patch has been merged into the patch attached to #7028 as both issues are tightly related. Will not update the patch here any more.

comment:11 Changed 14 years ago by Thomas Güttler

Cc: hv@… removed
Resolution: duplicate
Status: assignedclosed

See #7028

comment:12 Changed 13 years ago by EmilStenstrom

Here's a snippet that adds links to ManyToManyField too: http://djangosnippets.org/snippets/2217/

comment:13 Changed 12 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

comment:14 Changed 8 years ago by Hugo Osvaldo Barrera

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

Some of the latest patches from #7028 don't include this functionality any more - aside from the fact that the other issue has stagnated for a year now.

Can we reopen this, since it's simpler to implement alone? I'd be willing to work on it myself.

comment:16 Changed 8 years ago by Hugo Osvaldo Barrera

Cc: hugo@… added

comment:17 Changed 8 years ago by Tim Graham

Has patch: unset
Resolution: duplicate
Status: closednew
Type: UncategorizedNew feature

Seems fine to me. What about if the user doesn't have the "change" permission though? In that case we'll be outputting a link that leads to a "Permission Denied" page. It's not immediately obvious to me if there's a way to address that.

comment:18 Changed 8 years ago by Hugo Osvaldo Barrera

We can check if the user has change permissions before rendering the link.

We already do this to show the magnifying glass, I just need to dig into it a bit. I'll get back on this ASAP.

comment:19 Changed 8 years ago by Hugo Osvaldo Barrera

We already do this to show the magnifying glass, I just need to dig into it a bit. I'll get back on this ASAP.

Scrub that, the magnifying glass to select a related model is also shown if there are no permissions. There seems to be no clean way of avoiding a link to a 403 page - but it *is* consistent with the rest of the widget's behaviour (it's also a bit debatable if it's right to exclude the link or not).

I'm attaching an updated patch (GitHub is down ATM). It also uses the current admin site, rather than the default admin instance (which I noticed right away on my test app which uses several admin instances).

Changed 8 years ago by Hugo Osvaldo Barrera

Patch updated to apply on current master

comment:20 Changed 8 years ago by Hugo Osvaldo Barrera

Owner: changed from Julian Bez to Hugo Osvaldo Barrera
Status: newassigned

comment:21 Changed 8 years ago by Hugo Osvaldo Barrera

Has patch: set

comment:22 Changed 8 years ago by Tim Graham

Patch needs improvement: set

Left comments for improvement on the pull request.

comment:23 Changed 8 years ago by Hugo Osvaldo Barrera

Patch needs improvement: unset

comment:24 Changed 8 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 8bf8d0e:

Fixed #7923 -- Added links to objects displayed by ModelAdmin.raw_id_fields.

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