So, here is a simple short code that will generate the class object for you, just pass in various details :-)
def Formfactory(model, exclude_list, data=None, instance=None):
"""
An abstraction layer for forms and models
"""
class AbstractForm(djangoforms.ModelForm):
class Meta:
pass
setattr(Meta, 'model', model)
setattr(Meta, 'exclude', exclude_list)
myForm = AbstractForm(data=data, instance=instance)
return myForm
### Usage
t = Formfactory(Person, ['created_by', 'date_of_joining'] , data={'Name':'pranny'})
It can be normally used with all the is_valid() and rest.
Hope you will find it useful. Don't forget to comment.
bro plz tell me how to get .name domain name
ReplyDeleteplz reply me at umesh2020@yahoo.co.in
i m thenkful to u
btw nice blog