Opened 16 years ago
Closed 11 years ago
#13163 closed New feature (fixed)
Display link to change-form on inlines where model is registered in admin site
| Reported by: | Simon Meers | Owned by: | Simon Meers |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | inline link |
| Cc: | sree@…, cg@…, glicerinu@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | yes |
Description
If an inline object has a get_absolute_url method, a 'View on site' link is displayed.
Here I propose that if an inline object is registered in the same admin site, an 'Edit' link is displayed in a similar fashion.
Why?
- The inline may only display a subset of fields, so the user may wish to go to the full change form
- 'Recursive inlines' can be accessed more easily -- e.g.
HouseholdhasPersoninlines, andPersonhasPhoneinlines, etc.
The attached patch shows a draft implementation.
Questions:
- Do we need to check if the user has change permissions on that model before displaying the link? (in the unlikely event that the user has permission to change a model which displays the inlines of a model which they do not have change permissions for). Given that I cannot see a straightforward way of checking for this without the addition of a template tag/filter, and the rarity of such setups, I'd be happy to let the user click the link and get a permission denied page.
- Do we need an
InlineModelAdminoption for enabling/disabling this link? E.g.InlineModelAdmin.show_admin_link. Or are we happy to have it enabled globally? - Is
[ Edit ]a sufficiently understandable link label? Would "Edit in Admin", or "Display full form" or something be more appropriate?
I think the reciprocal of this would also be very useful -- ForeignKey widgets could display an [edit] link beside the "add new" (green +) link which links to the change form for the selected parent object.
Attachments (5)
Change History (27)
by , 16 years ago
| Attachment: | admin_url.diff added |
|---|
comment:1 by , 16 years ago
| milestone: | 1.2 |
|---|
This is a feature request and thus not appropriate for the 1.2 milestone at this point.
comment:2 by , 16 years ago
| Component: | django.contrib.admin → User Experience |
|---|---|
| Owner: | removed |
| Triage Stage: | Unreviewed → Accepted |
Sounds like a reasonable idea; reassigning to UX because it reflects on the UX of the admin, not admin code itself.
comment:3 by , 16 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
by , 15 years ago
| Attachment: | combined_13163_13165.diff added |
|---|
comment:4 by , 15 years ago
| milestone: | → 1.3 |
|---|
comment:5 by , 15 years ago
| Cc: | added |
|---|
comment:6 by , 15 years ago
| Cc: | added |
|---|
comment:7 by , 15 years ago
| Type: | → New feature |
|---|
comment:8 by , 15 years ago
| Severity: | → Normal |
|---|
comment:9 by , 15 years ago
| Easy pickings: | unset |
|---|
With Django 1.3 does not work. Is there anything like that under 1.3 ?
comment:10 by , 15 years ago
| Patch needs improvement: | set |
|---|
combined_13165_13165.diff fails to apply cleanly on to trunk
comment:11 by , 14 years ago
| UI/UX: | set |
|---|
comment:12 by , 14 years ago
| Component: | User Experience → contrib.admin |
|---|
by , 14 years ago
| Attachment: | inline_edit_link.diff added |
|---|
Add show_edit_link = True to your ObjectInline and you get an edit link
comment:13 by , 14 years ago
| Needs tests: | set |
|---|
Hey guys, I've just added above my own implementation of this feature. Very simple, just 3 lines of code but does the job.
(This patch does it only in tabular.html).
class BooksInline(admin.TabularInline): model = Book show_edit_link = True
comment:17 by , 14 years ago
| Cc: | added |
|---|
comment:18 by , 13 years ago
by , 13 years ago
| Attachment: | inline_edit_link-2.diff added |
|---|
modifed version edit_inline_link.diff that supports inlined models from other apps
comment:19 by , 11 years ago
@smcoll:
It looks like there is a wrong if in your patch: {% if inline_admin_form.original %}. It should check for the new show_edit_link option probably.
I assume that it won't work for many2many inlines, where you have model = Foo.bars.through?
comment:20 by , 11 years ago
| Needs documentation: | set |
|---|---|
| Needs tests: | unset |
| Patch needs improvement: | unset |
PR here: https://github.com/django/django/pull/2957.
I added a method AdminSite.is_registered() which takes a Model class or lowercased model name. This is needed for checking if the InlineModelAdmin's model is also registered as a ModelAdmin on the site. There is precedence for this sort of check with registries -- the app registry has apps.is_installed(), and it seems to be a reasonable method to have on the AdminSite.
Renamed the show_edit_link to show_change_link for consistency across the admin. The link will only be displayed if show_change_link = True on the inline, the model itself is also registered, and there is an inline object to change.
comment:22 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
InlineAdminForm changes, stacked/tabular template updates and regression tests