#18072: ChangeList shouldn't use hardcoded urls -------------------------------+-------------------- Reporter: kmike | Owner: nobody Type: Uncategorized | Status: new Component: contrib.admin | Version: 1.4 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------+-------------------- Some urls are still hardcoded in admin: ChangeList.url_for_result returns implicit relative url https://code.djangoproject.com/browser/django/trunk/django/contrib/admin/views/main.py#L377
Noticed this while implementing custom AdminSite that shows a changelist of one of the models as an index page (edit links were incorrect): {{{ class RestaurantPanel(admin.AdminSite): main_model = None @never_cache def index(self, request, extra_context=None): model_admin = self._registry[self.main_model] return model_admin.changelist_view(request, extra_context) }}} This ChangeList subclass fixed the issue for me: {{{ class FixedChangeList(ChangeList): def url_for_result(self, result): admin_name = self.model_admin.admin_site.name pk = getattr(result, self.pk_attname) return reverse("%s:%s_%s_change" % ( admin_name, self.opts.app_label, self.opts.module_name ), args=[pk]) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/18072> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.