diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2019-06-12 07:39:39 +0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-12 12:15:40 +0200 |
| commit | 6fa71872aefb974c16f0c51db423d710ef54c467 (patch) | |
| tree | 71d34e15237cc29657f5509a47059d1e7aca29f1 | |
| parent | b616f65855e5658a0272506ded1274516daa908d (diff) | |
Simplified django.urls.reverse() a bit.
| -rw-r--r-- | django/urls/base.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/django/urls/base.py b/django/urls/base.py index 1e11e05bec..1200d9a25b 100644 --- a/django/urls/base.py +++ b/django/urls/base.py @@ -36,10 +36,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): if not isinstance(viewname, str): view = viewname else: - parts = viewname.split(':') - parts.reverse() - view = parts[0] - path = parts[1:] + *path, view = viewname.split(':') if current_app: current_path = current_app.split(':') @@ -50,8 +47,7 @@ def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): resolved_path = [] ns_pattern = '' ns_converters = {} - while path: - ns = path.pop() + for ns in path: current_ns = current_path.pop() if current_path else None # Lookup the name to see if it could be an app identifier. try: |
