diff options
| author | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-04-30 15:32:29 +0000 |
|---|---|---|
| committer | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-04-30 15:32:29 +0000 |
| commit | 5a7802586d117a75f91df04c032fd249808a877d (patch) | |
| tree | 0750adbf26c907344f018eb2a73b77ae31c383cc /tests | |
| parent | 3b479bfc563d3b3d768640ff5963947c56ee042b (diff) | |
boulder-oracle-sprint: Merged to [5127]
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5128 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/model_forms/models.py | 41 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 2 |
2 files changed, 40 insertions, 3 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py index 2757787571..a23529b566 100644 --- a/tests/modeltests/model_forms/models.py +++ b/tests/modeltests/model_forms/models.py @@ -24,6 +24,12 @@ a commit=True parameter. from django.db import models +ARTICLE_STATUS = ( + (1, 'Draft'), + (2, 'Pending'), + (3, 'Live'), +) + class Category(models.Model): name = models.CharField(maxlength=20) url = models.CharField('The URL', maxlength=40) @@ -44,6 +50,7 @@ class Article(models.Model): writer = models.ForeignKey(Writer) article = models.TextField() categories = models.ManyToManyField(Category, blank=True) + status = models.IntegerField(choices=ARTICLE_STATUS, blank=True, null=True) def save(self): import datetime @@ -147,8 +154,8 @@ Create a couple of Writers. >>> w = Writer(name='Bob Woodward') >>> w.save() -ManyToManyFields are represented by a MultipleChoiceField, and ForeignKeys are -represented by a ChoiceField. +ManyToManyFields are represented by a MultipleChoiceField, ForeignKeys and any +fields with the 'choices' attribute are represented by a ChoiceField. >>> ArticleForm = form_for_model(Article) >>> f = ArticleForm(auto_id=False) >>> print f @@ -160,6 +167,12 @@ represented by a ChoiceField. <option value="2">Bob Woodward</option> </select></td></tr> <tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr> +<tr><th>Status:</th><td><select name="status"> +<option value="" selected="selected">---------</option> +<option value="1">Draft</option> +<option value="2">Pending</option> +<option value="3">Live</option> +</select></td></tr> <tr><th>Categories:</th><td><select multiple="multiple" name="categories"> <option value="1">Entertainment</option> <option value="2">It's a test</option> @@ -200,6 +213,12 @@ current values are inserted as 'initial' data in each Field. <option value="2">Bob Woodward</option> </select></li> <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> +<li>Status: <select name="status"> +<option value="" selected="selected">---------</option> +<option value="1">Draft</option> +<option value="2">Pending</option> +<option value="3">Live</option> +</select></li> <li>Categories: <select multiple="multiple" name="categories"> <option value="1">Entertainment</option> <option value="2">It's a test</option> @@ -232,6 +251,12 @@ Add some categories and test the many-to-many form output. <option value="2">Bob Woodward</option> </select></li> <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> +<li>Status: <select name="status"> +<option value="" selected="selected">---------</option> +<option value="1">Draft</option> +<option value="2">Pending</option> +<option value="3">Live</option> +</select></li> <li>Categories: <select multiple="multiple" name="categories"> <option value="1" selected="selected">Entertainment</option> <option value="2">It's a test</option> @@ -310,6 +335,12 @@ the data in the database when the form is instantiated. <option value="2">Bob Woodward</option> </select></li> <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> +<li>Status: <select name="status"> +<option value="" selected="selected">---------</option> +<option value="1">Draft</option> +<option value="2">Pending</option> +<option value="3">Live</option> +</select></li> <li>Categories: <select multiple="multiple" name="categories"> <option value="1">Entertainment</option> <option value="2">It's a test</option> @@ -329,6 +360,12 @@ the data in the database when the form is instantiated. <option value="3">Carl Bernstein</option> </select></li> <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> +<li>Status: <select name="status"> +<option value="" selected="selected">---------</option> +<option value="1">Draft</option> +<option value="2">Pending</option> +<option value="3">Live</option> +</select></li> <li>Categories: <select multiple="multiple" name="categories"> <option value="1">Entertainment</option> <option value="2">It's a test</option> diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 4e321b2d2b..9be8f022f6 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -217,7 +217,7 @@ class Templates(unittest.TestCase): # If a variable has a __str__() that returns a Unicode object, the # value will be converted to a bytestring. - 'basic-syntax18': (r'{{ var }}', {'var': UnicodeInStrClass()}, '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91'), + 'filter-syntax18': (r'{{ var }}', {'var': UnicodeInStrClass()}, '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91'), ### COMMENT SYNTAX ######################################################## 'comment-syntax01': ("{# this is hidden #}hello", {}, "hello"), |
