[Django] #34162: Wrong URL generated by get_admin_url in admin index "Recent Actions" panel in custom Django Admin Site

30 views
Skip to first unread message

Django

unread,
Nov 15, 2022, 9:04:35 PM11/15/22
to django-...@googlegroups.com
#34162: Wrong URL generated by get_admin_url in admin index "Recent Actions" panel
in custom Django Admin Site
-----------------------------------------+------------------------
Reporter: Rigo-Villalta | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 4.0
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 custom Admin Site is generated the method {{{ get_admin_url }}} of
the class {{{ LogEntry }}} in {{{ contrib/admin/models }}} generates a
link to {{{ /admin/... }}} instead of {{{ /custom-admin/... }}}

This is the code of the method:

{{{
if self.content_type and self.object_id:
url_name = "admin:%s_%s_change" % (
self.content_type.app_label,
self.content_type.model,
)
try:
return reverse(url_name, args=(quote(self.object_id),))
}}}

The problem here is that the class LogEntry has not an instance of Admin
Site as in this ticket: [https://code.djangoproject.com/ticket/33077] .

I have tested this bug in Django 3.2, 3.1 and 4.0

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

Django

unread,
Nov 16, 2022, 7:24:23 AM11/16/22
to django-...@googlegroups.com
#34162: Wrong URL generated by get_admin_url in admin index "Recent Actions" panel
in custom Django Admin Site
------------------------------------+--------------------------------------
Reporter: Rigoberto Villalta | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

Thanks for the ticket, I think we can mark this as a duplicate of #17726.
Resolving URLs to a proper admin site should fix both issues.

--
Ticket URL: <https://code.djangoproject.com/ticket/34162#comment:1>

Django

unread,
Nov 16, 2022, 11:47:04 AM11/16/22
to django-...@googlegroups.com
#34162: Wrong URL generated by get_admin_url in admin index "Recent Actions" panel
in custom Django Admin Site
------------------------------------+--------------------------------------
Reporter: Rigoberto Villalta | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by Rigoberto Villalta):

I don´t think is duplicate.
What the ticket [https://code.djangoproject.com/ticket/17726 #17726]
alleges is that if you change a {{{Model}}} A in a custom {{{Admin Site}}}
and this {{{Model}}} is not register in other {{{Admin Site}}} instance,
this shouldn't appear in the index of the other {{{Admin Site}}} instance.

What I am trying to fix is that at least to point the {{{Logentry}}} in
the index to the current {{{Admin Site}}}.
I most said this bug only happens if you register the Default Admin Site
in the project's {{{url.py}}} file:
{{{
path("super_admin/", admin.site.urls)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34162#comment:2>

Django

unread,
Nov 16, 2022, 1:21:21 PM11/16/22
to django-...@googlegroups.com
#34162: Wrong URL generated by get_admin_url in admin index "Recent Actions" panel
in custom Django Admin Site
------------------------------------+--------------------------------------
Reporter: Rigoberto Villalta | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:2 Rigoberto Villalta]:


> I don´t think is duplicate.

It's not exactly the same but resolving URLs to a proper admin site would
fix both issues.

--
Ticket URL: <https://code.djangoproject.com/ticket/34162#comment:3>

Reply all
Reply to author
Forward
0 new messages