Opened 18 years ago
Closed 18 years ago
#3278 closed defect (fixed)
newforms class names get overwritten
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In root/django/trunk/django/newforms/forms.py, the definition of DeclarativeFieldsMetaclass inadvertently overwrites the Forms class's name:
29 class DeclarativeFieldsMetaclass(type):
30 "Metaclass that converts Field attributes to a dictionary called 'fields'."
31 def new(cls, name, bases, attrs):
32 fields = [(name, attrs.pop(name)) for name, obj in attrs.items() if isinstance(obj, Field)]
33 fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter))
34 attrsfields = SortedDictFromList(fields)
35 return type.new(cls, name, bases, attrs)
Fix: In line 32 [only], change "name" to anything else! (Note that "name" is also one of the method arguments!)
Change History (3)
comment:1 by , 18 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 18 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
comment:3 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Sorry for the mess in original comment -- the code fragment should be as follows: