Extend comment about admin URL patching

fix_request_path_info
Jonas Haag 2015-10-26 10:07:46 +01:00 committed by Hugo Osvaldo Barrera
parent 17583d15b3
commit ee2e0a95ea
1 changed files with 7 additions and 2 deletions

View File

@ -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
# /<app>/<model>/<pk>/ to /<app>/<model>/<pk>/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),