Skip to content

Instantly share code, notes, and snippets.

@inoshiro
Last active December 18, 2015 10:59
Show Gist options
  • Save inoshiro/5772360 to your computer and use it in GitHub Desktop.
Save inoshiro/5772360 to your computer and use it in GitHub Desktop.
>>> from django import forms
>>> class CommentForm(forms.Form):
... name = forms.CharField(initial='class')
...
>>> f = CommentForm()
>>> print(f)
<tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" value="class" id="id_name" /></td></tr>
>>> f.fields['name'].initial
'class'
>>> class CommentForm(forms.Form):
... name = forms.CharField()
...
>>> f = CommentForm()
>>> f.fields['name'].initial
>>> print(f.fields['name'].initial)
None
>>> name = f.fields['name']
>>> f.initial
{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment