summaryrefslogtreecommitdiff
path: root/django/urls
diff options
context:
space:
mode:
authorChris Lamb <chris@chris-lamb.co.uk>2017-11-07 16:39:59 +0000
committerTim Graham <timograham@gmail.com>2017-11-07 11:39:59 -0500
commit998c9dd599cd907bb38f440fff13a808571589f8 (patch)
tree55bc5b404d0a3d33f1e2240cc0f5482e3324b2b1 /django/urls
parenta4f9ef4fe8048264c5d9e193e2ff79f735626c65 (diff)
Fixed #28663 -- Add a check for likely incorrectly migrated django.urls.path() routes.
Diffstat (limited to 'django/urls')
-rw-r--r--django/urls/resolvers.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
index 412b7458be..7e8187d95c 100644
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -255,7 +255,16 @@ class RoutePattern(CheckURLMixin):
return None
def check(self):
- return self._check_pattern_startswith_slash()
+ warnings = self._check_pattern_startswith_slash()
+ route = self._route
+ if '(?P<' in route or route.startswith('^') or route.endswith('$'):
+ warnings.append(Warning(
+ "Your URL pattern {} has a route that contains '(?P<', begins "
+ "with a '^', or ends with a '$'. This was likely an oversight "
+ "when migrating to django.urls.path().".format(self.describe()),
+ id='2_0.W001',
+ ))
+ return warnings
def _compile(self, route):
return re.compile(_route_to_regex(route, self._is_endpoint)[0])