diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-20 21:14:27 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:22 +0200 |
| commit | ee191715eae73362768184aa95206cf61bac5d38 (patch) | |
| tree | f6ffc0bf4dfaea9f91cf8536ba2aeb9a69a81a6d /django/forms | |
| parent | fa3f0aa021bea85b9196ef154a32c7bb1023a1e9 (diff) | |
[py3] Fixed access to dict keys/values/items.
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/extras/widgets.py | 2 | ||||
| -rw-r--r-- | django/forms/forms.py | 6 | ||||
| -rw-r--r-- | django/forms/models.py | 3 | ||||
| -rw-r--r-- | django/forms/widgets.py | 3 |
4 files changed, 7 insertions, 7 deletions
diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py index 4e11a4ee06..c5ca1424c8 100644 --- a/django/forms/extras/widgets.py +++ b/django/forms/extras/widgets.py @@ -79,7 +79,7 @@ class SelectDateWidget(Widget): year_val, month_val, day_val = [int(v) for v in match.groups()] choices = [(i, i) for i in self.years] year_html = self.create_select(name, self.year_field, value, year_val, choices) - choices = MONTHS.items() + choices = list(six.iteritems(MONTHS)) month_html = self.create_select(name, self.month_field, value, month_val, choices) choices = [(i, i) for i in range(1, 32)] day_html = self.create_select(name, self.day_field, value, day_val, choices) diff --git a/django/forms/forms.py b/django/forms/forms.py index 4d4cdbe3db..0f3fdb2e40 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -38,7 +38,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True): used. The distinction is useful in ModelForm subclassing. Also integrates any additional media definitions """ - fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] + fields = [(field_name, attrs.pop(field_name)) for field_name, obj in list(six.iteritems(attrs)) if isinstance(obj, Field)] fields.sort(key=lambda x: x[1].creation_counter) # If this class is subclassing another Form, add that Form's fields. @@ -47,11 +47,11 @@ def get_declared_fields(bases, attrs, with_base_fields=True): if with_base_fields: for base in bases[::-1]: if hasattr(base, 'base_fields'): - fields = base.base_fields.items() + fields + fields = list(six.iteritems(base.base_fields)) + fields else: for base in bases[::-1]: if hasattr(base, 'declared_fields'): - fields = base.declared_fields.items() + fields + fields = list(six.iteritems(base.declared_fields)) + fields return SortedDict(fields) diff --git a/django/forms/models.py b/django/forms/models.py index e6ae357d19..a2b5448b14 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -18,6 +18,7 @@ from django.utils.datastructures import SortedDict from django.utils import six from django.utils.text import get_text_list, capfirst from django.utils.translation import ugettext_lazy as _, ugettext +from django.utils import six __all__ = ( @@ -206,7 +207,7 @@ class ModelFormMetaclass(type): fields = fields_for_model(opts.model, opts.fields, opts.exclude, opts.widgets, formfield_callback) # make sure opts.fields doesn't specify an invalid field - none_model_fields = [k for k, v in fields.iteritems() if not v] + none_model_fields = [k for k, v in six.iteritems(fields) if not v] missing_fields = set(none_model_fields) - \ set(declared_fields.keys()) if missing_fields: diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 3c4da2444d..13b7d8e7f6 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -63,8 +63,7 @@ class Media(StrAndUnicode): 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 = self._css.keys() - media.sort() + media = sorted(self._css.keys()) return chain(*[ [format_html('<link href="{0}" type="text/css" media="{1}" rel="stylesheet" />', self.absolute_path(path), medium) for path in self._css[medium]] |
