From 5a7802586d117a75f91df04c032fd249808a877d Mon Sep 17 00:00:00 2001 From: Boulder Sprinters Date: Mon, 30 Apr 2007 15:32:29 +0000 Subject: 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 --- tests/modeltests/model_forms/models.py | 41 ++++++++++++++++++++++++++++++-- tests/regressiontests/templates/tests.py | 2 +- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'tests') 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. Article: +Status: Categories:
  • Article:
  • +
  • Status:
  • Categories:
  • Article:
  • +
  • Status:
  • Categories:
  • Article:
  • +
  • Status:
  • Categories:
  • Article:
  • +
  • Status:
  • Categories: