Opened 11 years ago

Closed 11 years ago

#19554 closed Uncategorized (invalid)

ChangeList.url_for_result work only for "admin" Site

Reported by: tecnosegugio@… Owned by: nobody
Component: contrib.admin Version: 1.5-beta-1
Severity: Normal Keywords: Admin, AdminSite, ChangeList
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django/contrib/admin/views/main.py the ChangeList.url_for_result method contains a format string with an hardcode "admin:".
With this string it's hard to get the correct URLs in a result list in an Admin Site different than the default.

As a workaround, I've edited the method as follow:

def url_for_result(self, result):
    pk = getattr(result, self.pk_attname)
    return reverse('%s:%s_%s_change' % (     # edited the format string
        self.model_admin.admin_site.name,    # added this parameter
        self.opts.app_label,
        self.opts.module_name),
        args=(quote(pk),),
        current_app=self.model_admin.admin_site.name
    )

Change History (2)

comment:1 by anonymous, 11 years ago

Summary: ChangeList.url_for_result iwork only for "admin" SiteChangeList.url_for_result work only for "admin" Site

comment:2 by Rafal Stozek, 11 years ago

Resolution: invalid
Status: newclosed

current_app argument decides what instance of admin site is being used. admin in format string is application name, not an instance name.

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