Prevent infinite redirection on django1.9
See here[1] as to why this is an issue, and why we can skip the avoided code on django>=1.9. [1]: https://docs.djangoproject.com/en/1.9/releases/1.9/#django-contrib-adminfix_request_path_info
parent
f28b0b5172
commit
e73a4662c3
|
|
@ -18,6 +18,7 @@ from django.utils.encoding import force_text
|
|||
from django.utils.http import urlencode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import django
|
||||
|
||||
|
||||
try:
|
||||
|
|
@ -298,7 +299,13 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin):
|
|||
|
||||
# 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.
|
||||
new_change_url = url(r'^{0}/$'.format(self.pk_regex), self.admin_site.admin_view(self.change_view), name='{0}_{1}_change'.format(*info))
|
||||
if django.VERSION < (1, 9):
|
||||
new_change_url = url(
|
||||
r'^{0}/$'.format(self.pk_regex),
|
||||
self.admin_site.admin_view(self.change_view),
|
||||
name='{0}_{1}_change'.format(*info)
|
||||
)
|
||||
|
||||
for i, oldurl in enumerate(urls):
|
||||
if oldurl.name == new_change_url.name:
|
||||
urls[i] = new_change_url
|
||||
|
|
|
|||
Loading…
Reference in New Issue