Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#34162 closed Bug (duplicate)

Wrong URL generated by get_admin_url in admin index "Recent Actions" panel in custom Django Admin Site

Reported by: Rigoberto Villalta Owned by: nobody
Component: contrib.admin Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (3)

comment:1 by Mariusz Felisiak, 18 months ago

Resolution: duplicate
Status: newclosed

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.

comment:2 by Rigoberto Villalta, 18 months ago

I don´t think is duplicate.
What the ticket #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)

in reply to:  2 comment:3 by Mariusz Felisiak, 18 months ago

Replying to 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.

Note: See TracTickets for help on using tickets.
Back to Top