mirror of
https://github.com/django/django.git
synced 2025-07-19 17:19:12 +00:00
[1.0.X] Fixed #9780 -- Fixed an undefined internal link in the model forms documentation, thanks ramiro.
Backport of r9670 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9671 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6c3a98ab3a
commit
518e19a363
@ -110,6 +110,8 @@ attempt to provide an article, but fail to do so::
|
|||||||
As we can see the formset properly performed validation and gave us the
|
As we can see the formset properly performed validation and gave us the
|
||||||
expected errors.
|
expected errors.
|
||||||
|
|
||||||
|
.. _understanding-the-managementform:
|
||||||
|
|
||||||
Understanding the ManagementForm
|
Understanding the ManagementForm
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -197,7 +197,8 @@ accepts either ``True`` or ``False``. If you call ``save()`` with
|
|||||||
the database. In this case, it's up to you to call ``save()`` on the resulting
|
the database. In this case, it's up to you to call ``save()`` on the resulting
|
||||||
model instance. This is useful if you want to do custom processing on the
|
model instance. This is useful if you want to do custom processing on the
|
||||||
object before saving it, or if you want to use one of the specialized
|
object before saving it, or if you want to use one of the specialized
|
||||||
:ref:`model saving options <ref-models-force-insert>`. ``commit`` is ``True`` by default.
|
:ref:`model saving options <ref-models-force-insert>`. ``commit`` is ``True``
|
||||||
|
by default.
|
||||||
|
|
||||||
Another side effect of using ``commit=False`` is seen when your model has
|
Another side effect of using ``commit=False`` is seen when your model has
|
||||||
a many-to-many relation with another model. If your model has a many-to-many
|
a many-to-many relation with another model. If your model has a many-to-many
|
||||||
@ -272,7 +273,7 @@ specify ``fields`` or ``exclude`` like this::
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Author
|
model = Author
|
||||||
fields = ('name', 'title')
|
fields = ('name', 'title')
|
||||||
|
|
||||||
class PartialAuthorForm(ModelForm):
|
class PartialAuthorForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Author
|
model = Author
|
||||||
@ -429,7 +430,7 @@ Alternatively, you can create a subclass that implements a ``get_queryset()``
|
|||||||
method::
|
method::
|
||||||
|
|
||||||
from django.forms.models import BaseModelFormSet
|
from django.forms.models import BaseModelFormSet
|
||||||
|
|
||||||
class BaseAuthorFormSet(BaseModelFormSet):
|
class BaseAuthorFormSet(BaseModelFormSet):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super(BaseAuthorFormSet, self).get_queryset().filter(name__startswith='O')
|
return super(BaseAuthorFormSet, self).get_queryset().filter(name__startswith='O')
|
||||||
@ -496,7 +497,7 @@ number of objects needed::
|
|||||||
|
|
||||||
>>> Author.objects.order_by('name')
|
>>> Author.objects.order_by('name')
|
||||||
[<Author: Charles Baudelaire>, <Author: Paul Verlaine>, <Author: Walt Whitman>]
|
[<Author: Charles Baudelaire>, <Author: Paul Verlaine>, <Author: Walt Whitman>]
|
||||||
|
|
||||||
>>> AuthorFormSet = modelformset_factory(Author, max_num=2, extra=1)
|
>>> AuthorFormSet = modelformset_factory(Author, max_num=2, extra=1)
|
||||||
>>> formset = AuthorFormSet(queryset=Author.objects.order_by('name'))
|
>>> formset = AuthorFormSet(queryset=Author.objects.order_by('name'))
|
||||||
>>> formset.initial
|
>>> formset.initial
|
||||||
@ -583,7 +584,8 @@ itself::
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
When you manually render the forms yourself, be sure to render the management
|
When you manually render the forms yourself, be sure to render the management
|
||||||
form as shown above. See the :ref:`management form documentation <understanding-the-managementform>`.
|
form as shown above. See the :ref:`management form documentation
|
||||||
|
<understanding-the-managementform>`.
|
||||||
|
|
||||||
Third, you can manually render each field::
|
Third, you can manually render each field::
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user