Re: [Django] #13165: Display edit link beside add button for ForeignKey fields in admin

94 views
Skip to first unread message

Django

unread,
Aug 23, 2011, 5:43:18 AM8/23/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: DrMeers
Type: New | Status: reopened
feature | Component: contrib.admin
Milestone: 1.3 | Severity: Normal
Version: SVN | Keywords: admin foreign key
Resolution: | edit link
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 1 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Changes (by anonymous):

* easy: => 0


Comment:

Hi - I'm just about to start hacking something like this together... any
idea when it might make it into trunk? If there is anything useful I can
do...

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:32>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 24, 2011, 9:00:50 AM8/24/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: DrMeers
Type: New | Status: reopened
feature | Component: contrib.admin
Milestone: 1.3 | Severity: Normal
Version: SVN | Keywords: admin foreign key
Resolution: | edit link
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 1 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------

Comment (by julien):

Replying to [comment:32 anonymous]:

> Hi - I'm just about to start hacking something like this together... any
idea when it might make it into trunk? If there is anything useful I can
do...

We're approaching the alpha/beta release stages so the earlier one starts
to work on this and the closer one gets to a fully functional and fully
tested code, the higher the chance it has to be included in core. Any
contribution is appreciated ;-)

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:33>

Django

unread,
Sep 23, 2011, 1:29:17 PM9/23/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New | Status: new
feature | Component: contrib.admin
Milestone: 1.3 | Severity: Normal
Version: SVN | Keywords: admin foreign key
Resolution: | edit link
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Changes (by stefanw):

* owner: DrMeers => stefanw
* needs_better_patch: 1 => 0
* status: reopened => new


Comment:

I ported the latest patch to trunk including the following additional
changes:

- CSS names now contain - (dashes) instead of _ (underscores)
- link generation in admin.util.get_changelink_html includes escaping

The related-field-changelink CSS class needs some styling (like vertical-
align: middle or something).

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:34>

Django

unread,
Sep 26, 2011, 10:10:23 AM9/26/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New | Status: assigned
feature | Component: contrib.admin
Milestone: 1.3 | Severity: Normal
Version: SVN | Keywords: admin foreign key
Resolution: | edit link
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Changes (by stefanw):

* status: new => assigned
* cc: stefanw (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:35>

Django

unread,
Oct 4, 2011, 5:38:29 PM10/4/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: SVN
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by stefanw):

* needs_better_patch: 0 => 1


Comment:

jezdez commented in irc and disliked the OPs approach of retrieving the
object and wanted the change link to change when a different fk object is
selected.

There is a pull request with some open questions:
https://github.com/django/django/pull/57

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:37>

Django

unread,
Oct 5, 2011, 3:42:56 PM10/5/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: SVN
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by stefanw):

I posted to the django-ux list about this ticket:
https://groups.google.com/forum/#!topic/django-ux/dzkQogwfx4I

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:38>

Django

unread,
Oct 7, 2011, 8:01:43 PM10/7/11
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: SVN
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

Here's a little something I implemented for a project. It adds the edit /
delete link and enable / disable them when nothing is selected. Plus
saving an object after deleting (via popup) updates the repr of the object
in the select box.

* [http://dl.dropbox.com/u/2759157/empty.png]
* [http://dl.dropbox.com/u/2759157/selected.png]
* [http://www.youtube.com/watch?v=H4xqku-BPBU] A short demo

The code can be found on django snippet at
[http://djangosnippets.org/snippets/2562/]. I think we should consider
adding the delete link also.

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:39>

Django

unread,
May 6, 2012, 3:25:05 PM5/6/12
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by brillgen):

* cc: dev@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:40>

Django

unread,
May 10, 2012, 4:29:58 PM5/10/12
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

Comment comment:39 was me. I packaged a simple app providing admin mixins
to add a the edition and deletion links described above. You can find the
project on [https://github.com/charettes/django-admin-enhancer github] and
on [http://pypi.python.org/pypi/django-admin-enhancer/0.1.0 pypi].

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:41>

Django

unread,
Dec 20, 2012, 8:58:04 AM12/20/12
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by guettli):

* cc: hv@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:42>

Django

unread,
Feb 5, 2013, 10:11:12 AM2/5/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: stefanw
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by BinaryKhaos):

* cc: ua_django_bugzilla@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:43>

Django

unread,
Nov 19, 2013, 12:33:32 AM11/19/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes

Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* owner: stefanw => charettes


Comment:

@stefanw hope you don't mind I assign this ticket to myself but I'm
working on adapting the django-admin-enhancer code to merge it into
Django. You can follow the WIP
[https://github.com/charettes/django/compare/ticket-13165-edit-and-delete-
links here].

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:44>

Django

unread,
Nov 26, 2013, 9:03:57 AM11/26/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by danielsamuels):

* cc: danielsamuels (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:45>

Django

unread,
Dec 23, 2013, 12:08:30 AM12/23/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

I've been working on this lately and
[https://github.com/charettes/django/compare/ticket-13165-edit-and-delete-
links almost everything is working correctly].

The last missing part concerns foreign keys with `to_field` since there's
no way to retrieve the related object based on the selected `to_field`
value.

We've got two options here:

1. Provides views redirecting to the related object change and delete
views based on the provided `to_field` value;
2. Attach a `data-pk` attribute on all options (in the case of `Select`
widget) or to the raw id input to retrieve.

The second option doesn't seems viable since it's requires a lot of
special casing when dealing with different types of widgets.

The first one should be doable by allowing `ModelAdmin.get_object` to
receive a third parameter specifying which field to retrieve it's model
from.

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:46>

Django

unread,
Dec 23, 2013, 1:28:02 AM12/23/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

I opened a [https://github.com/django/django/pull/2104 Pull Request] with
a working implementation of 1.

I'd appreciated feedback on the possible `from_field` attack vector those
changes introduce. One solution would be to restrict allowed `from_field`
values based on current admin site registered models pointing to the
actual model being looked up.

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:47>

Django

unread,
Dec 23, 2013, 2:33:50 AM12/23/13
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

I added the `from_field` [https://github.com/django/django/pull/2104/files
#diff-3c42de3e53aba87b32c494f995a728dfR613 restriction].

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:48>

Django

unread,
Oct 5, 2014, 11:18:28 PM10/5/14
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by collinanderson):

* cc: cmawebsite@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:49>

Django

unread,
Nov 15, 2014, 1:06:29 PM11/15/14
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 1
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by charettes):

Created a PR with the changes. It's only missing documentation and a way
to deal with the two broken public APIs.

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:50>

Django

unread,
Jan 2, 2015, 6:44:28 PM1/2/15
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by charettes):

* needs_better_patch: 1 => 0


Comment:

Added what was missing to ship with 1.8. Review would be greatly
appreciated.

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:51>

Django

unread,
Jan 9, 2015, 2:39:26 PM1/9/15
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin foreign key | Triage Stage: Accepted
edit link 1.8-alpha |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by timgraham):

* keywords: admin foreign key edit link => admin foreign key edit link
1.8-alpha


--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:52>

Django

unread,
Jan 10, 2015, 12:25:19 PM1/10/15
to django-...@googlegroups.com
#13165: Display edit link beside add button for ForeignKey fields in admin
-------------------------------------+-------------------------------------
Reporter: DrMeers | Owner: charettes
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: admin foreign key | Triage Stage: Accepted
edit link 1.8-alpha |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"07988744b347302925bc6cc66511e34224db55ab"]:
{{{
#!CommitTicketReference repository=""
revision="07988744b347302925bc6cc66511e34224db55ab"
Fixed #13165 -- Added edit and delete links to admin foreign key widgets.

Thanks to Collin Anderson for the review and suggestions and Tim for the
final review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/13165#comment:53>

Reply all
Reply to author
Forward
0 new messages