mirror of https://github.com/django/django.git
Used OrderedDict.fromkeys() to initialize OrderedDict with None values.
This commit is contained in:
parent
939d923e8e
commit
fac74b84a3
|
@ -627,8 +627,8 @@ class ModelAdmin(BaseModelAdmin):
|
|||
exclude = exclude or None
|
||||
|
||||
# Remove declared form fields which are in readonly_fields.
|
||||
new_attrs = OrderedDict(
|
||||
(f, None) for f in readonly_fields
|
||||
new_attrs = OrderedDict.fromkeys(
|
||||
f for f in readonly_fields
|
||||
if f in self.form.declared_fields
|
||||
)
|
||||
form = type(self.form.__name__, (self.form,), new_attrs)
|
||||
|
|
|
@ -87,8 +87,8 @@ class Command(BaseCommand):
|
|||
if len(app_labels) == 0:
|
||||
if primary_keys:
|
||||
raise CommandError("You can only use --pks option with one model")
|
||||
app_list = OrderedDict(
|
||||
(app_config, None) for app_config in apps.get_app_configs()
|
||||
app_list = OrderedDict.fromkeys(
|
||||
app_config for app_config in apps.get_app_configs()
|
||||
if app_config.models_module is not None and app_config not in excluded_apps
|
||||
)
|
||||
else:
|
||||
|
|
|
@ -10,7 +10,7 @@ class OrderedSet:
|
|||
"""
|
||||
|
||||
def __init__(self, iterable=None):
|
||||
self.dict = OrderedDict(((x, None) for x in iterable) if iterable else [])
|
||||
self.dict = OrderedDict.fromkeys(iterable or ())
|
||||
|
||||
def add(self, item):
|
||||
self.dict[item] = None
|
||||
|
|
Loading…
Reference in New Issue