Ticket #7617: models.diff
File models.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/newforms/models.py
215 215 216 216 217 217 class ModelFormMetaclass(type): 218 def __new__(cls, name, bases, attrs, 219 formfield_callback=lambda f: f.formfield()): 218 def __new__(cls, name, bases, attrs): 219 formfield_callback = attrs.pop('formfield_callback', 220 lambda f: f.formfield()) 220 221 try: 221 222 parents = [b for b in bases if issubclass(b, ModelForm)] 222 223 except NameError: 223 224 # We are defining ModelForm itself. 224 225 parents = None 226 new_class = super(ModelFormMetaclass, cls).__new__(cls, name, bases, 227 attrs) 225 228 if not parents: 226 return super(ModelFormMetaclass, cls).__new__(cls, name, bases, 227 attrs) 228 229 new_class = type.__new__(cls, name, bases, attrs) 229 return new_class 230 230 if 'media' not in attrs: 231 231 new_class.media = media_property(new_class) 232 232 declared_fields = get_declared_fields(bases, attrs, False) … … 289 289 setattr(Meta, 'fields', fields) 290 290 setattr(Meta, 'exclude', exclude) 291 291 class_name = model.__name__ + 'Form' 292 return ModelFormMetaclass(class_name, (form,), {'Meta': Meta}, 293 formfield_callback=formfield_callback) 292 return ModelFormMetaclass(class_name, (form,), 293 {'Meta': Meta, 294 'formfield_callback': formfield_callback}) 294 295 295 296 296 297 # ModelFormSets ##############################################################