diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-08-05 17:15:33 +0000 |
| commit | aa239e3e5405933af6a29dac3cf587b59a099927 (patch) | |
| tree | ea2cbd139c9a8cf84c09e0b2008bff70e05927ef /docs/modelforms.txt | |
| parent | 45b73c9a4685809236f84046cc7ffd32a50db958 (diff) | |
gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.archive/attic/gis
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8215 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/modelforms.txt')
| -rw-r--r-- | docs/modelforms.txt | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/modelforms.txt b/docs/modelforms.txt index 9c06bc409d..1be7c3a882 100644 --- a/docs/modelforms.txt +++ b/docs/modelforms.txt @@ -1,6 +1,6 @@ -========================== -Using newforms with models -========================== +======================= +Using forms with models +======================= ``ModelForm`` ============= @@ -16,7 +16,7 @@ class from a Django model. For example:: - >>> from django.newforms import ModelForm + >>> from django.forms import ModelForm # Create the form class. >>> class ArticleForm(ModelForm): @@ -86,11 +86,11 @@ the full list of conversions: As you might expect, the ``ForeignKey`` and ``ManyToManyField`` model field types are special cases: - * ``ForeignKey`` is represented by ``django.newforms.ModelChoiceField``, + * ``ForeignKey`` is represented by ``django.forms.ModelChoiceField``, which is a ``ChoiceField`` whose choices are a model ``QuerySet``. * ``ManyToManyField`` is represented by - ``django.newforms.ModelMultipleChoiceField``, which is a + ``django.forms.ModelMultipleChoiceField``, which is a ``MultipleChoiceField`` whose choices are a model ``QuerySet``. In addition, each generated form field has attributes set as follows: @@ -121,7 +121,7 @@ A full example Consider this set of models:: from django.db import models - from django.newforms import ModelForm + from django.forms import ModelForm TITLE_CHOICES = ( ('MR', 'Mr.'), @@ -240,14 +240,14 @@ For example:: >>> new_author = f.save() Other than the ``save()`` and ``save_m2m()`` methods, a ``ModelForm`` -works exactly the same way as any other ``newforms`` form. For +works exactly the same way as any other ``forms`` form. For example, the ``is_valid()`` method is used to check for validity, the ``is_multipart()`` method is used to determine whether a form requires multipart file upload (and hence whether ``request.FILES`` must be -passed to the form), etc. See `the standard newforms documentation`_ +passed to the form), etc. See `the standard forms documentation`_ for more information. -.. _the standard newforms documentation: ../newforms/ +.. _the standard forms documentation: ../forms/ Using a subset of fields on the form ------------------------------------ @@ -384,7 +384,7 @@ Similar to regular formsets there are a couple enhanced formset classes that provide all the right things to work with your models. Lets reuse the ``Author`` model from above:: - >>> from django.newforms.models import modelformset_factory + >>> from django.forms.models import modelformset_factory >>> AuthorFormSet = modelformset_factory(Author) This will create a formset that is capable of working with the data associated @@ -417,7 +417,7 @@ configurable:: Alternatively, you can use a subclassing based approach:: - from django.newforms.models import BaseModelFormSet + from django.forms.models import BaseModelFormSet class BaseAuthorFormSet(BaseModelFormSet): def get_queryset(self): @@ -494,7 +494,7 @@ with related objects through a foreign key. Suppose you have two models ``Author`` and ``Book``. You want to create a formset that works with the books of a specific author. Here is how you could accomplish this:: - >>> from django.newforms.models import inlineformset_factory + >>> from django.forms.models import inlineformset_factory >>> BookFormSet = inlineformset_factory(Author, Book) >>> author = Author.objects.get(name=u'Orson Scott Card') >>> formset = BookFormSet(instance=author) |
