mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Deprecated SortedDict (replaced with collections.OrderedDict)
Thanks Loic Bistuer for the review.
This commit is contained in:
committed by
Tim Graham
parent
b278f7478d
commit
07876cf02b
@@ -4,6 +4,7 @@ Form classes
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
import copy
|
||||
import warnings
|
||||
|
||||
@@ -11,7 +12,6 @@ from django.core.exceptions import ValidationError
|
||||
from django.forms.fields import Field, FileField
|
||||
from django.forms.util import flatatt, ErrorDict, ErrorList
|
||||
from django.forms.widgets import Media, media_property, TextInput, Textarea
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.html import conditional_escape, format_html
|
||||
from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
|
||||
from django.utils.safestring import mark_safe
|
||||
@@ -55,7 +55,7 @@ def get_declared_fields(bases, attrs, with_base_fields=True):
|
||||
if hasattr(base, 'declared_fields'):
|
||||
fields = list(six.iteritems(base.declared_fields)) + fields
|
||||
|
||||
return SortedDict(fields)
|
||||
return OrderedDict(fields)
|
||||
|
||||
class DeclarativeFieldsMetaclass(type):
|
||||
"""
|
||||
|
||||
@@ -5,6 +5,7 @@ and database field objects.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from collections import OrderedDict
|
||||
import warnings
|
||||
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError
|
||||
@@ -15,7 +16,6 @@ from django.forms.util import ErrorList
|
||||
from django.forms.widgets import (SelectMultiple, HiddenInput,
|
||||
MultipleHiddenInput, media_property, CheckboxSelectMultiple)
|
||||
from django.utils.encoding import smart_text, force_text
|
||||
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, string_concat
|
||||
@@ -142,7 +142,7 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None,
|
||||
formfield_callback=None, localized_fields=None,
|
||||
labels=None, help_texts=None, error_messages=None):
|
||||
"""
|
||||
Returns a ``SortedDict`` containing form fields for the given model.
|
||||
Returns a ``OrderedDict`` containing form fields for the given model.
|
||||
|
||||
``fields`` is an optional list of field names. If provided, only the named
|
||||
fields will be included in the returned fields.
|
||||
@@ -199,9 +199,9 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None,
|
||||
field_list.append((f.name, formfield))
|
||||
else:
|
||||
ignored.append(f.name)
|
||||
field_dict = SortedDict(field_list)
|
||||
field_dict = OrderedDict(field_list)
|
||||
if fields:
|
||||
field_dict = SortedDict(
|
||||
field_dict = OrderedDict(
|
||||
[(f, field_dict.get(f)) for f in fields
|
||||
if ((not exclude) or (exclude and f not in exclude)) and (f not in ignored)]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user