#33077: Wrong URL generated by get_admin_url for readonly field in custom Admin
Site
-----------------------------------------+------------------------
Reporter: Ken Whitesell | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
When a model containing a `ForeignKey` field is viewed (or edited) in a
custom Admin Site, and that `ForeignKey` field is listed in
`readonly_fields`, the url generated for the link is `/admin/...` instead
of `/custom-admin/...`.
This appears to be caused by the following line in
`django.contrib.admin.helpers` `get_admin_url`:
`url = reverse(url_name, args=[quote(remote_obj.pk)])`
Other parts of the admin use the `current_app` keyword parameter to
identify the correct current name of the Admin Site. (See
django.contrib.admin.options.ModelAdmin response_add as just one example)
I have been able to correct this specific issue by replacing the above
line with:
{{{
url = reverse(
url_name,
args=[quote(remote_obj.pk)],
current_app=self.model_admin.admin_site.name
)
}}}
However, I don't know if there are any side effects and I have not yet run
the full suite of tests on this. Mostly looking for feedback whether I'm
on the right track.
--
Ticket URL: <https://code.djangoproject.com/ticket/33077>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.bba106d72041cb3c73afccb0b08b6b17%40djangoproject.com.