summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-29 16:32:18 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-11-29 16:32:18 +0000
commitd0f5a58fbd73e1a9ccef405e16ac070787e98fd4 (patch)
treece29f623565f86138d038e64694b8355730f738c /docs
parenta4ea8d4e939295178b593ebeaf15269b658e8a6a (diff)
Fixed #4653 -- Improved the logic to decide when to include (and select as
initial value) the blank choice for a model field with choices. Thanks to Ilya Semenov for persisting with this. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/newforms.txt18
1 files changed, 13 insertions, 5 deletions
diff --git a/docs/newforms.txt b/docs/newforms.txt
index 593e9216d7..5feb2e6a02 100644
--- a/docs/newforms.txt
+++ b/docs/newforms.txt
@@ -1849,7 +1849,11 @@ In addition, each generated form field has attributes set as follows:
* If the model field has ``choices`` set, then the form field's ``widget``
will be set to ``Select``, with choices coming from the model field's
- ``choices``.
+ ``choices``. The choices will normally include the blank choice which is
+ selected by default. If the field is required, this forces the user to
+ make a selection. The blank choice will not be included if the model
+ field has ``blank=False`` and an explicit ``default`` value (the
+ ``default`` value will be initially selected instead).
Finally, note that you can override the form field used for a given model
field. See "Overriding the default field types" below.
@@ -2095,10 +2099,14 @@ instance instead of a model class::
# Instantiate the form.
>>> f = AuthorForm()
-When a form created by ``form_for_instance()`` is created, the initial
-data values for the form fields are drawn from the instance. However,
-this data is not bound to the form. You will need to bind data to the
-form before the form can be saved.
+When a form created by ``form_for_instance()`` is created, the initial data
+values for the form fields are drawn from the instance. However, this data is
+not bound to the form. You will need to bind data to the form before the form
+can be saved.
+
+Unlike ``form_for_model()``, a choice field in form created by
+``form_for_instance()`` will not include the blank choice if the respective
+model field has ``blank=False``. The initial choice is drawn from the instance.
When you call ``save()`` on a form created by ``form_for_instance()``,
the database instance will be updated. As in ``form_for_model()``, ``save()``