Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added small newforms unit test

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 97256bc commit 5bec651a61ac9ba2831850104060833b37403399 @adrianholovaty adrianholovaty committed
Showing with 13 additions and 0 deletions.
  1. +13 −0 tests/regressiontests/forms/
13 tests/regressiontests/forms/
@@ -2011,6 +2011,19 @@
<option value="J">Java</option>
+A subtlety: If one of the choices' value is the empty string and the form is
+unbound, then the <option> for the empty-string choice will get selected="selected".
+>>> class FrameworkForm(Form):
+... name = CharField()
+... language = ChoiceField(choices=[('', '------'), ('P', 'Python'), ('J', 'Java')])
+>>> f = FrameworkForm(auto_id=False)
+>>> print f['language']
+<select name="language">
+<option value="" selected="selected">------</option>
+<option value="P">Python</option>
+<option value="J">Java</option>
You can specify widget attributes in the Widget constructor.
>>> class FrameworkForm(Form):
... name = CharField()

0 comments on commit 5bec651

Please sign in to comment.
Something went wrong with that request. Please try again.