1
0
mirror of https://github.com/django/django.git synced 2025-04-15 04:44:37 +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
# Having keys in the resulting JSON makes it more useful
url_pattern_dicts = []
for route, view, name in url_patterns:
url_pattern_dict = {
"route": route,
"view": view,
"name": name,
}
url_pattern_dicts.append(url_pattern_dict)
url_pattern_dicts = [
{"route": route, "view": view, "name": name}
for route, view, name in url_patterns
]
return json.dumps(url_pattern_dicts, indent=indent)