summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-05-27 16:08:46 -0700
committerTim Graham <timograham@gmail.com>2017-05-27 19:08:46 -0400
commit21046e77734278cea871dce922220bf29aa5b7b4 (patch)
treee0820850a3d058c35307916da793668f7e5c48b3 /django/forms
parent2a5708a304cf337dbf556e2bd87a930079f8f766 (diff)
Fixed #28249 -- Removed unnecessary dict.keys() calls.
iter(dict) is equivalent to iter(dict.keys()).
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py5
-rw-r--r--django/forms/widgets.py2
2 files changed, 3 insertions, 4 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index b58d8e5b99..f4c415ed4f 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -248,8 +248,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass):
# make sure opts.fields doesn't specify an invalid field
none_model_fields = [k for k, v in fields.items() if not v]
- missing_fields = (set(none_model_fields) -
- set(new_class.declared_fields.keys()))
+ missing_fields = set(none_model_fields) - set(new_class.declared_fields)
if missing_fields:
message = 'Unknown field(s) (%s) specified for %s'
message = message % (', '.join(missing_fields),
@@ -317,7 +316,7 @@ class BaseModelForm(BaseForm):
# Exclude fields that failed form validation. There's no need for
# the model fields to validate them as well.
- elif field in self._errors.keys():
+ elif field in self._errors:
exclude.append(f.name)
# Exclude empty fields that are not required by the form, if the
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 37c11f1241..5b47aa691d 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -63,7 +63,7 @@ class Media:
def render_css(self):
# To keep rendering order consistent, we can't just iterate over items().
# We need to sort the keys, and iterate over the sorted list.
- media = sorted(self._css.keys())
+ media = sorted(self._css)
return chain.from_iterable([
format_html(
'<link href="{}" type="text/css" media="{}" rel="stylesheet" />',