[Answered ]-Get initial data of form fields

1👍

for field in SettingsForm().fields:
    print field.initial

1👍

for django1.4, this works

for k,v in SettingsForm().fields.iteritems():
    print v.initial

0👍

You might be able to do something like this:

class SettingsForm(forms.ModelForm):
    theme = forms.CharField(required=True, initial='yellow')
    defaultinputmessage = forms.CharField(required=True, initial='Type here')

f = SettingsForm(auto_id=False)
    print f

Give it a try…

👤Alex

Leave a comment