We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 27fbac2 commit 464fcd0Copy full SHA for 464fcd0
cbv/views.py
@@ -1,3 +1,4 @@
1
+from collections import defaultdict
2
from typing import Any
3
4
import attrs
@@ -105,12 +106,9 @@ def get_prepared_attributes(
105
106
) -> models.QuerySet["KlassAttribute"]:
107
attributes = class_.get_attributes()
108
# Make a dictionary of attributes based on name
- attribute_names: dict[str, list[KlassAttribute]] = {}
109
+ attribute_names: dict[str, list[KlassAttribute]] = defaultdict(list)
110
for attr in attributes:
- try:
111
- attribute_names[attr.name] += [attr]
112
- except KeyError:
113
- attribute_names[attr.name] = [attr]
+ attribute_names[attr.name].append(attr)
114
115
ancestors = class_.get_all_ancestors()
116
0 commit comments