Skip to content

Commit

Permalink
make django 2.0.6 compatible by adding converters to get_ns_resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
R. van der Vegt committed Jun 27, 2018
1 parent ec4b350 commit 63d4732
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion arctic/utils.py
Expand Up @@ -112,6 +112,7 @@ def view_from_url(named_url): # noqa
current_path = None
resolved_path = []
ns_pattern = ''
ns_converters = {}

while path:
ns = path.pop()
Expand Down Expand Up @@ -140,6 +141,10 @@ def view_from_url(named_url): # noqa
extra, resolver = resolver.namespace_dict[ns]
resolved_path.append(ns)
ns_pattern = ns_pattern + extra
try:
ns_converters.update(resolver.pattern.converters)
except Exception:
pass
except KeyError as key:
if resolved_path:
raise NoReverseMatch(
Expand All @@ -149,7 +154,11 @@ def view_from_url(named_url): # noqa
raise NoReverseMatch("%s is not a registered namespace" %
key)
if ns_pattern:
resolver = get_ns_resolver(ns_pattern, resolver)
try:
resolver = get_ns_resolver(ns_pattern, resolver,
tuple(ns_converters.items()))
except Exception:
resolver = get_ns_resolver(ns_pattern, resolver)

# custom code, get view from reverse_dict
reverse_dict = resolver.reverse_dict.dict()
Expand Down

0 comments on commit 63d4732

Please sign in to comment.