Skip to content

Commit

Permalink
Fixed django#3278 -- newforms: Fixed bug in DeclarativeFieldsMetaclas…
Browse files Browse the repository at this point in the history
…s where it inadvertently overrode the class' name. Thanks, russblau@imapmail.org

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jan 10, 2007
1 parent 2144a2c commit f6a7002
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion django/newforms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, data=None):
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)
Expand Down
6 changes: 3 additions & 3 deletions tests/regressiontests/forms/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@
>>> 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
<tr><th><label for="id_first_name">First name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="first_name" id="id_first_name" /></td></tr>
<tr><th><label for="id_last_name">Last name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="last_name" id="id_last_name" /></td></tr>
Expand Down Expand Up @@ -1585,7 +1585,7 @@
>>> 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
<tr><th><label for="id_first_name">First name:</label></th><td><input type="text" name="first_name" id="id_first_name" /></td></tr>
<tr><th><label for="id_last_name">Last name:</label></th><td><input type="text" name="last_name" id="id_last_name" /></td></tr>
Expand Down Expand Up @@ -1627,7 +1627,7 @@
>>> p.clean_data
Traceback (most recent call last):
...
AttributeError: 'birthday' object has no attribute 'clean_data'
AttributeError: 'Person' object has no attribute 'clean_data'
>>> p['first_name'].errors
[u'This field is required.']
>>> p['first_name'].errors.as_ul()
Expand Down

0 comments on commit f6a7002

Please sign in to comment.