Opened 18 years ago
Closed 15 years ago
#2569 closed enhancement (duplicate)
[patch] Admin page Foreign Key improvements
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | pythonmailing@… | Triage Stage: | Someday/Maybe |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This patch provides two changes to the admin page. Firstly, one-to-one mappings can now be clicked on to be taken to that object. Secondly a new button allows you to edit a foreign key object in same way that you can add one.
The reason for this is that we are using the django admin page to make an asset tracker, and so far I've been impressed by how powerful the admin pages are. Unfortunately with highly normalized data its a pain to have so few paths for getting to objects. This patch should streamline the process a bit.
At the moment I have the looking glass icon to denote editing the element. Probably want to use a new edit icon. I'll attach one to this ticket if I can get a friend to make one.
Attachments (4)
Change History (11)
by , 18 years ago
Attachment: | adminforeign.diff added |
---|
comment:1 by , 18 years ago
Hi Joel;
I like the idea of these extra navigation links quite a lot; but I had a few problems with the patch.
First, one-to-one field related links are broken. They expect the bound field's existing_display method to return the related object's primary key; this is not the case - they return the related object itself. This might work if the related object's str returns it's primary key, but that's definitely not the case for most of my models. I had to add a related_key field with the related object's primary key in AdminBoundField.
Secondly, it expectes ADD_SLASHES to be turned on - which it is by default, but wasn't on my machine. This incurs a redirection everytime you click on a related item link, though, and can be fixed by adding "/" to the path in the showEditPopup javascript function.
Also, it would be nice if links were available on both sides of a one-to-one relationship. It looks like that might be a lot more work though.
comment:2 by , 18 years ago
Jim,
Well spotted on those issues - I've now fixed both. I made a slight change to the javascript which means it now works with inline fields.
I agree it would be very nice to have a link back for one-to-one fields that reference this object. But then this would probably be useful not just for one-to-one fields but also for any type of related field and it probably should have its own separate place in the admin page.
comment:3 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Guys - can you raise this issue in django-developers? These all sound like good improvements to make, and we should see what the core developers think.
comment:4 by , 17 years ago
Cc: | added |
---|
I found out that ticket #4028 requests more or less what's developed here. Was there any discussion in django-developers? I'd be interessted to see it in the Django admin. Malcolm Tredinnick closed that ticket, but the newform-admin is still not merged, unfortunately.
by , 17 years ago
Attachment: | adminforeign.2.rev6000.diff added |
---|
The adminforeign.2.diff ported to SVN revision 6000
comment:5 by , 17 years ago
Version: | 0.95 → SVN |
---|
I tested the adminrelated.2.diff
, applied it to the quite recent revision 6000 and it went more or less clean. One hunk was rejected but it turned out not to absolutely neccessary. It works well, althought I suspect that there will be crashes. But on the first look it looks promising. I am planning to port both adminrelated.2.diff
which works with One-to-Many relationships and adminrelated.3.diff
which works with One-to-One relationships to a current SVN revision, hopefully for inclusion in the trunk.
comment:6 by , 17 years ago
Triage Stage: | Design decision needed → Someday/Maybe |
---|
At some point, we'll be reworking the admin interface, and this will be one of the things we examine at that time.
comment:7 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
The admin code has changed too much since this patch was created; I suggest moving discussions to #13165 (which I guess is technically the real duplicate), which has a newer patch. We still have some admin permission issues to solve before getting the patches committed. There are some design decisions to be made regarding dynamic linking using JavaScript also. See discussions at http://groups.google.com/group/django-developers/browse_thread/thread/8812e50dfa1a3a8
diff file for the patch