[1.8.x] Fixed #24221 - Used precompiled regexp for percent-placeholder matching.
Backport of ea0ea7859a
from master
This commit is contained in:
parent
09e8985f25
commit
2d990fb7fa
|
@ -12,6 +12,8 @@ from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
|
||||||
from django.views.generic.detail import (SingleObjectMixin,
|
from django.views.generic.detail import (SingleObjectMixin,
|
||||||
SingleObjectTemplateResponseMixin, BaseDetailView)
|
SingleObjectTemplateResponseMixin, BaseDetailView)
|
||||||
|
|
||||||
|
PERCENT_PLACEHOLDER_REGEX = re.compile(r'%\([^\)]+\)') # RemovedInDjango20Warning
|
||||||
|
|
||||||
|
|
||||||
class FormMixinBase(type):
|
class FormMixinBase(type):
|
||||||
def __new__(cls, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
|
@ -163,7 +165,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
|
||||||
Returns the supplied URL.
|
Returns the supplied URL.
|
||||||
"""
|
"""
|
||||||
if self.success_url:
|
if self.success_url:
|
||||||
if re.search(r'%\([^\)]+\)', self.success_url):
|
if PERCENT_PLACEHOLDER_REGEX.search(self.success_url):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"%()s placeholder style in success_url is deprecated. "
|
"%()s placeholder style in success_url is deprecated. "
|
||||||
"Please replace them by the {} Python format syntax.",
|
"Please replace them by the {} Python format syntax.",
|
||||||
|
@ -297,7 +299,7 @@ class DeletionMixin(object):
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
if self.success_url:
|
if self.success_url:
|
||||||
if re.search(r'%\([^\)]+\)', self.success_url):
|
if PERCENT_PLACEHOLDER_REGEX.search(self.success_url):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"%()s placeholder style in success_url is deprecated. "
|
"%()s placeholder style in success_url is deprecated. "
|
||||||
"Please replace them by the {} Python format syntax.",
|
"Please replace them by the {} Python format syntax.",
|
||||||
|
|
Loading…
Reference in New Issue