Simplified django.urls.reverse() a bit.
This commit is contained in:
parent
b616f65855
commit
6fa71872ae
|
@ -36,10 +36,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
|
||||||
if not isinstance(viewname, str):
|
if not isinstance(viewname, str):
|
||||||
view = viewname
|
view = viewname
|
||||||
else:
|
else:
|
||||||
parts = viewname.split(':')
|
*path, view = viewname.split(':')
|
||||||
parts.reverse()
|
|
||||||
view = parts[0]
|
|
||||||
path = parts[1:]
|
|
||||||
|
|
||||||
if current_app:
|
if current_app:
|
||||||
current_path = current_app.split(':')
|
current_path = current_app.split(':')
|
||||||
|
@ -50,8 +47,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
|
||||||
resolved_path = []
|
resolved_path = []
|
||||||
ns_pattern = ''
|
ns_pattern = ''
|
||||||
ns_converters = {}
|
ns_converters = {}
|
||||||
while path:
|
for ns in path:
|
||||||
ns = path.pop()
|
|
||||||
current_ns = current_path.pop() if current_path else None
|
current_ns = current_path.pop() if current_path else None
|
||||||
# Lookup the name to see if it could be an app identifier.
|
# Lookup the name to see if it could be an app identifier.
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue