Changeset 8020 for django/trunk/docs/form_for_model.txt
- Timestamp:
- 07/21/08 11:38:54 (5 months ago)
- Files:
-
- django/trunk/docs/form_for_model.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/form_for_model.txt
r7294 r8020 21 21 -------------------- 22 22 23 The method ``django. newforms.form_for_model()`` creates a form based on the23 The method ``django.forms.form_for_model()`` creates a form based on the 24 24 definition of a specific model. Pass it the model class, and it will return a 25 25 ``Form`` class that contains a form field for each model field. … … 27 27 For example:: 28 28 29 >>> from django. newforms import form_for_model29 >>> from django.forms import form_for_model 30 30 31 31 # Create the form class. … … 94 94 types are special cases: 95 95 96 * ``ForeignKey`` is represented by ``django. newforms.ModelChoiceField``,96 * ``ForeignKey`` is represented by ``django.forms.ModelChoiceField``, 97 97 which is a ``ChoiceField`` whose choices are a model ``QuerySet``. 98 98 99 99 * ``ManyToManyField`` is represented by 100 ``django. newforms.ModelMultipleChoiceField``, which is a100 ``django.forms.ModelMultipleChoiceField``, which is a 101 101 ``MultipleChoiceField`` whose choices are a model ``QuerySet``. 102 102 … … 229 229 230 230 If you want to add custom methods to the form generated by 231 ``form_for_model()``, write a class that extends ``django. newforms.BaseForm``231 ``form_for_model()``, write a class that extends ``django.forms.BaseForm`` 232 232 and contains your custom methods. Then, use the ``form`` argument to 233 233 ``form_for_model()`` to tell it to use your custom form as its base class. … … 413 413 form field. 414 414 415 .. _contact form: ../ newforms/#simple-view-example416 .. _`simple example view`: ../ newforms/#simple-view-example415 .. _contact form: ../forms/#simple-view-example 416 .. _`simple example view`: ../forms/#simple-view-example 417 417 418 418 When should you use ``form_for_model()`` and ``form_for_instance()``?
