I'm trying to create dynamic form with corresponding fields using following code. But getting problem while submiting value.
If i entered blank value then error is :
Attribute Error:
'module' object has no attribute ''
in forms.py, and if I entered value for salary then error is:
Attribute Error:
'module' object has no attribute '100000'
in forms.py
Here is forms.py
from django import forms
class ContextForm(forms.Form):
def __init__(self. rdict, *args, **kwargs):
super(ContextForm, self).__init__(*args, **kwargs)
for key in rdict.keys():
self.fields['%s' % str(key)] = getattr(forms,rdict.get(key))()
rdict = {'address': 'CharField','phone': 'CharField', 'Salary': 'IntegerField','first name': 'CharField','last name':'CharField'}
c = ContextForm(rdict)