From ee2e0a95ea5eb3b7c2be2e51b4869fa5331ca853 Mon Sep 17 00:00:00 2001 From: Jonas Haag Date: Mon, 26 Oct 2015 10:07:46 +0100 Subject: [PATCH] Extend comment about admin URL patching --- polymorphic/admin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/polymorphic/admin.py b/polymorphic/admin.py index b89588d..1adba55 100644 --- a/polymorphic/admin.py +++ b/polymorphic/admin.py @@ -296,9 +296,14 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin): urls = super(PolymorphicParentModelAdmin, self).get_urls() info = _get_opt(self.model) - # Patch the change URL so it's not a big catch-all; allowing all custom URLs to be added to the end. - # The url needs to be recreated, patching url.regex is not an option Django 1.4's LocaleRegexProvider changed it. + # Patch the change view URL so it's not a big catch-all; allowing all + # custom URLs to be added to the end. This is done by adding '/$' to the + # end of the regex. The url needs to be recreated, patching url.regex + # is not an option Django 1.4's LocaleRegexProvider changed it. if django.VERSION < (1, 9): + # On Django 1.9, the change view URL has been changed from + # //// to ////change/, which is + # why we can skip this workaround for Django >= 1.9. new_change_url = url( r'^{0}/$'.format(self.pk_regex), self.admin_site.admin_view(self.change_view),