Ticket #6115: modelform_for_model.diff

File modelform_for_model.diff, 642 bytes (added by Øyvind Saltvik <oyvind@…>, 17 years ago)

modelform_for_model

  • django/newforms/models.py

     
    288288class ModelForm(BaseModelForm):
    289289    __metaclass__ = ModelFormMetaclass
    290290
     291def modelform_for_model(model, form=ModelForm, **kwargs):
     292    kwargs['model'] = model
     293    opts = model._meta
     294    options = type('%sModelFormMeta' % opts.object_name, (object,) , kwargs)
     295    return type('%sModelForm' % opts.object_name, (form,) , {'Meta': options})
    291296
    292297# Fields #####################################################################
    293298
Back to Top