From c6798d63ba9ddc105734cb76c331ca8146c80479 Mon Sep 17 00:00:00 2001 From: Chris Guo Date: Tue, 13 Aug 2019 21:55:08 +0800 Subject: [PATCH] fix dynamic route can't match url rightly --- rest_framework/routers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rest_framework/routers.py b/rest_framework/routers.py index ee5760e81..a87b91597 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -38,8 +38,12 @@ def escape_curly_brackets(url_path): """ Double brackets in regex of url_path for escape string formatting """ - if ('{' and '}') in url_path: - url_path = url_path.replace('{', '{{').replace('}', '}}') + if '{' in url_path: + url_path = url_path.replace('{', '{{') + + if '}' in url_path: + url_path = url_path.replace('}', '}}') + return url_path