diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-01-21 01:29:01 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-01-21 01:29:01 +0000 |
| commit | 76f6dd42cc3c763d9f64c2c8f74f244613ae771b (patch) | |
| tree | 0566af7e6356c2385d5212ed8a09b37febb2a437 /tests | |
| parent | f073318668a40aab280a5e367e725e08538c52e3 (diff) | |
Fixed #3196 -- Fixed inconsistency in setting choices on ChoiceFields dynamically
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4379 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index b1425bef6d..5f003711dc 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1866,6 +1866,21 @@ defined on the Field, not the ones defined on the Widget. <option value="J">Java</option> </select> +You can set a ChoiceField's choices after the fact. +>>> class FrameworkForm(Form): +... name = CharField() +... language = ChoiceField() +>>> f = FrameworkForm(auto_id=False) +>>> print f['language'] +<select name="language"> +</select> +>>> f.fields['language'].choices = [('P', 'Python'), ('J', 'Java')] +>>> print f['language'] +<select name="language"> +<option value="P">Python</option> +<option value="J">Java</option> +</select> + Add widget=RadioSelect to use that widget with a ChoiceField. >>> class FrameworkForm(Form): ... name = CharField() |
