Opened 13 years ago
Closed 13 years ago
#19554 closed Uncategorized (invalid)
ChangeList.url_for_result work only for "admin" Site
| Reported by: | 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 , 13 years ago
| Summary: | ChangeList.url_for_result iwork only for "admin" Site → ChangeList.url_for_result work only for "admin" Site |
|---|
comment:2 by , 13 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
current_appargument decides what instance of admin site is being used.adminin format string is application name, not an instance name.