Fixed #21516 -- Updated imports paths for some formset functions/classes.

Since refs #21489, FormSet classes and factories are exposed on the
django.forms package.
This commit is contained in:
Bryan Marty 2015-10-27 18:37:35 -07:00 committed by Tim Graham
parent dbe79d9660
commit 455034d4df
3 changed files with 29 additions and 29 deletions

View file

@ -698,7 +698,7 @@ You can create forms from a given model using the standalone function
definition. This may be more convenient if you do not have many customizations
to make::
>>> from django.forms.models import modelform_factory
>>> from django.forms import modelform_factory
>>> from myapp.models import Book
>>> BookForm = modelform_factory(Book, fields=("author", "title"))
@ -729,7 +729,7 @@ Like :doc:`regular formsets </topics/forms/formsets>`, Django provides a couple
of enhanced formset classes that make it easy to work with Django models. Let's
reuse the ``Author`` model from above::
>>> from django.forms.models import modelformset_factory
>>> from django.forms import modelformset_factory
>>> from myapp.models import Author
>>> AuthorFormSet = modelformset_factory(Author, fields=('name', 'title'))
@ -773,7 +773,7 @@ queryset that includes all objects in the model (e.g.,
Alternatively, you can create a subclass that sets ``self.queryset`` in
``__init__``::
from django.forms.models import BaseModelFormSet
from django.forms import BaseModelFormSet
from myapp.models import Author
class BaseAuthorFormSet(BaseModelFormSet):
@ -941,7 +941,7 @@ Using a model formset in a view
Model formsets are very similar to formsets. Let's say we want to present a
formset to edit ``Author`` model instances::
from django.forms.models import modelformset_factory
from django.forms import modelformset_factory
from django.shortcuts import render_to_response
from myapp.models import Author
@ -975,7 +975,7 @@ the unique constraints on your model (either ``unique``, ``unique_together`` or
on a ``ModelFormSet`` and maintain this validation, you must call the parent
class's ``clean`` method::
from django.forms.models import BaseModelFormSet
from django.forms import BaseModelFormSet
class MyModelFormSet(BaseModelFormSet):
def clean(self):
@ -991,7 +991,7 @@ have already been created for each ``Form``. Modifying a value in
to modify a value in ``ModelFormSet.clean()`` you must modify
``form.instance``::
from django.forms.models import BaseModelFormSet
from django.forms import BaseModelFormSet
class MyModelFormSet(BaseModelFormSet):
def clean(self):
@ -1009,7 +1009,7 @@ Using a custom queryset
As stated earlier, you can override the default queryset used by the model
formset::
from django.forms.models import modelformset_factory
from django.forms import modelformset_factory
from django.shortcuts import render_to_response
from myapp.models import Author
@ -1113,7 +1113,7 @@ you have these two models::
If you want to create a formset that allows you to edit books belonging to
a particular author, you could do this::
>>> from django.forms.models import inlineformset_factory
>>> from django.forms import inlineformset_factory
>>> BookFormSet = inlineformset_factory(Author, Book, fields=('title',))
>>> author = Author.objects.get(name='Mike Royko')
>>> formset = BookFormSet(instance=author)
@ -1137,7 +1137,7 @@ When overriding methods on ``InlineFormSet``, you should subclass
For example, if you want to override ``clean()``::
from django.forms.models import BaseInlineFormSet
from django.forms import BaseInlineFormSet
class CustomInlineFormSet(BaseInlineFormSet):
def clean(self):
@ -1152,7 +1152,7 @@ See also :ref:`model-formsets-overriding-clean`.
Then when you create your inline formset, pass in the optional argument
``formset``::
>>> from django.forms.models import inlineformset_factory
>>> from django.forms import inlineformset_factory
>>> BookFormSet = inlineformset_factory(Author, Book, fields=('title',),
... formset=CustomInlineFormSet)
>>> author = Author.objects.get(name='Mike Royko')