1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

Use list comprehension instead a for loop

This commit is contained in:
Ülgen Sarıkavak 2024-11-19 12:39:35 +03:00
parent a8deea21ce
commit e35596881f

View File

@ -213,14 +213,10 @@ class Command(BaseCommand):
indent = 4 if pretty else None indent = 4 if pretty else None
# Having keys in the resulting JSON makes it more useful # Having keys in the resulting JSON makes it more useful
url_pattern_dicts = [] url_pattern_dicts = [
for route, view, name in url_patterns: {"route": route, "view": view, "name": name}
url_pattern_dict = { for route, view, name in url_patterns
"route": route, ]
"view": view,
"name": name,
}
url_pattern_dicts.append(url_pattern_dict)
return json.dumps(url_pattern_dicts, indent=indent) return json.dumps(url_pattern_dicts, indent=indent)