Ticket #6197: models.diff
File models.diff, 1.3 KB (added by , 17 years ago) |
---|
-
models.py
214 214 self.exclude = getattr(options, 'exclude', None) 215 215 216 216 class ModelFormMetaclass(type): 217 def __new__(cls, name, bases, attrs): 218 # TODO: no way to specify formfield_callback yet, do we need one, or 219 # should it be a special case for the admin? 217 def __new__(cls, name, bases, attrs, 218 formfield_callback=lambda f: f.formfield()): 220 219 fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] 221 220 fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter)) 222 221 … … 253 252 base_model = getattr(base_opts, 'model', None) 254 253 if base_model is not None: 255 254 raise ImproperlyConfigured('%s defines more than one model.' % name) 256 model_fields = fields_for_model(opts.model, opts.fields, opts.exclude) 255 model_fields = fields_for_model(opts.model, opts.fields, opts.exclude, 256 formfields_callback) 257 257 # fields declared in base classes override fields from the model 258 258 model_fields.update(declared_fields) 259 259 attrs['base_fields'] = model_fields