diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 21c9722990..0b4687bcf3 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -29,7 +29,7 @@ class SortedDictFromList(SortedDict): class DeclarativeFieldsMetaclass(type): "Metaclass that converts Field attributes to a dictionary called 'fields'." def __new__(cls, name, bases, attrs): - fields = [(name, attrs.pop(name)) for name, obj in attrs.items() if isinstance(obj, Field)] + fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter)) attrs['fields'] = SortedDictFromList(fields) return type.__new__(cls, name, bases, attrs) diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 3b252fb5a9..ad77d5795e 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1551,7 +1551,7 @@ False >>> p.clean_data Traceback (most recent call last): ... -AttributeError: 'birthday' object has no attribute 'clean_data' +AttributeError: 'Person' object has no attribute 'clean_data' >>> print p