From 71ce11f617cc56024300b4fa968af345329c8ecd Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 28 Dec 2006 01:16:29 +0000 Subject: 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 --- tests/modeltests/model_forms/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') 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 +Name: """} -- cgit v1.3