Fixed curly bracket in regexp of @list_route

This commit is contained in:
이동환 2017-05-25 19:13:45 +09:00
parent 871ce34983
commit e6c9f89a12

View File

@ -35,6 +35,12 @@ DynamicDetailRoute = namedtuple('DynamicDetailRoute', ['url', 'name', 'initkwarg
DynamicListRoute = namedtuple('DynamicListRoute', ['url', 'name', 'initkwargs'])
def replace_curly_brackets(url_path):
if ('{' and '}') in url_path:
url_path = url_path.replace('{', '{{').replace('}', '}}')
return url_path
def replace_methodname(format_string, methodname):
"""
Partially format a format_string, swapping out any
@ -178,6 +184,7 @@ class SimpleRouter(BaseRouter):
initkwargs = route.initkwargs.copy()
initkwargs.update(method_kwargs)
url_path = initkwargs.pop("url_path", None) or methodname
url_path = replace_curly_brackets(url_path)
url_name = initkwargs.pop("url_name", None) or url_path
ret.append(Route(
url=replace_methodname(route.url, url_path),