summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-12-28 01:16:29 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-12-28 01:16:29 +0000
commit71ce11f617cc56024300b4fa968af345329c8ecd (patch)
treee38468847cf26abd61b01cd47fdd7cb32105f7b2 /tests
parent2cb0fe71a2131a4b9e61b6da98888051bfad58b1 (diff)
newforms: Implemented form_for_instance(). The resulting Form class does not yet have a method that saves the changes
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/model_forms/models.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index 566dad42ea..8ae9ddc6fb 100644
--- a/tests/modeltests/model_forms/models.py
+++ b/tests/modeltests/model_forms/models.py
@@ -36,7 +36,7 @@ class Article(models.Model):
return self.headline
__test__ = {'API_TESTS': """
->>> from django.newforms import form_for_model, BaseForm
+>>> from django.newforms import form_for_model, form_for_instance, BaseForm
>>> Category.objects.all()
[]
@@ -141,4 +141,13 @@ subclass of BaseForm, not Form.
>>> f = CategoryForm()
>>> f.say_hello()
hello
+
+Use form_for_instance to create a Form from a model instance. The difference
+between this Form and one created via form_for_model is that the object's
+current values are inserted as 'initial' data in each Field.
+>>> w = Writer.objects.get(name='Mike Royko')
+>>> RoykoForm = form_for_instance(w)
+>>> f = RoykoForm(auto_id=False)
+>>> print f
+<tr><th>Name:</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" /></td></tr>
"""}