Ticket #13524: 13524.2.diff

File 13524.2.diff, 9.9 KB (added by Ramiro Morales, 14 years ago)

Fixed two typos

  • docs/ref/contrib/admin/index.txt

    diff -r b126ac58b50a docs/ref/contrib/admin/index.txt
    a b  
    10531053passed through to ``inlineformset_factory`` when creating the formset for this
    10541054inline.
    10551055
     1056.. _ref-contrib-admin-inline-extra:
     1057
    10561058``extra``
    10571059~~~~~~~~~
    10581060
     
    10621064
    10631065.. versionadded:: 1.2
    10641066
    1065 Extra forms for inlines will be hidden and replaced with a link to dynamically
    1066 add any number of new inlines for users with Javascript enabled.
     1067Extra forms for inlines will be hidden and replaced with a "Add another" link to
     1068dynamically add any number of new inlines for users with JavaScript enabled.
     1069
     1070That dynamic link will not appear if ``max_num`` is less than the number of
     1071currently displayed forms.
     1072
     1073.. _ref-contrib-admin-inline-max-num:
    10671074
    10681075``max_num``
    10691076~~~~~~~~~~~
  • docs/releases/1.2.txt

    diff -r b126ac58b50a docs/releases/1.2.txt
    a b  
    351351only time this should ever be an issue is if you were expecting printing the
    352352``repr`` of a ``BooleanField`` to print ``1`` or ``0``.
    353353
     354Changed semantics of ``max_num`` in formsets, model formsets
     355------------------------------------------------------------
     356
     357As part of enhancements made to the handling of formsets and model formsets,
     358the semantics and default values of the ``max_num`` parameters to the
     359:ref:`django.forms.formsets.formset_factory() <formsets-max-num>` and
     360:ref:`django.forms.models.modelformset_factory() <model-formsets-max-num>`
     361functions have been changed in 1.2.
     362
     363Previously, the default values for these parameters were ``0`` (zero) and they
     364indicated no limit had to be imposed by the formset machinery to the number of
     365generated forms. Starting with 1.2, the value used to specify that is ``None``
     366and it's also the new default value. This frees the ``0`` value so the developer
     367can use it to:
     368
     369    * For ``formset_factory()``: To force no form to be generated at all in the
     370      formset when an instance is rendered, irrespective of the value of the
     371      ``extra`` parameter or the value of the ``initial`` parameter passed to
     372      the class ``__init__`` method.
     373
     374    * For ``modelformset_factory()``: To force no extra blank forms to exist
     375      when an instance of the model formset class is rendered, irrespective of
     376      the value of the ``extra`` parameter. The forms representing existing
     377      model instances pased in the ``queryset`` parameter to the class
     378      ``__init__`` method are always shown, no truncation of these forms is
     379      performed.
     380
     381As model formsets are the basis of the admin app inlines functionality, these
     382changes also apply to the equally-named ``max_num`` admin
     383``(Tabular|Stacked)Inline`` :ref:`option <ref-contrib-admin-inline-max-num>`.
     384
     385This means that if you were specifying a value of ``0`` for ``max_num`` or were
     386leaving its value out in one of these places relying on the previous default
     387values, then it is possible that you will need to review and modify your code in
     388such spots.
     389
     390.. seealso::
     391
     392    :ref:`1.2-js-assisted-inlines`
     393
    354394.. _deprecated-features-1.2:
    355395
    356396Features deprecated in 1.2
     
    611651``SpatialBackend``
    612652^^^^^^^^^^^^^^^^^^
    613653
    614 Prior to the creation of the separate spatial backends, the 
     654Prior to the creation of the separate spatial backends, the
    615655``django.contrib.gis.db.backend.SpatialBackend`` object was
    616656provided as an abstraction to introspect on the capabilities of
    617657the spatial database.  All of the attributes and routines provided by
     
    929969The currently used language code for Norwegian Bokmål ``no`` is being
    930970replaced by the more common language code ``nb``, which should be updated
    931971by translators from now on.
     972
     973.. _1.2-js-assisted-inlines:
     974
     975JavaScript-assisted handling of inline related objects in the admin app where available
     976---------------------------------------------------------------------------------------
     977
     978When using inline model formsets in the admin app, if the user browser has
     979JavaScript enabled then extra forms controlled by the ``extra``
     980``(Stacked|Tabular)Inline`` :ref:`option <ref-contrib-admin-inline-extra>` will
     981be hidden and replaced with a link to dynamically add any number of new inlines.
  • docs/topics/forms/formsets.txt

    diff -r b126ac58b50a docs/topics/forms/formsets.txt
    a b  
    6868
    6969    :ref:`Creating formsets from models with model formsets <model-formsets>`.
    7070
     71.. _formsets-max-num:
     72
    7173Limiting the maximum number of forms
    7274------------------------------------
    7375
     
    8385
    8486.. versionchanged:: 1.2
    8587
    86 If the value of ``max_num`` is geater than the number of existing related
     88If the value of ``max_num`` is geater than the number of existing
    8789objects, up to ``extra`` additional blank forms will be added to the formset,
    8890so long as the total number of forms does not exceed ``max_num``.
    8991
     
    9193forms displayed. Please note that the default value of ``max_num`` was changed
    9294from ``0`` to ``None`` in version 1.2 to allow ``0`` as a valid value.
    9395
    94 .. versionadded:: 1.2
    95 
    96 The dynamic "Add Another" link in the Django admin will not appear if
    97 ``max_num`` is less than the number of currently displayed forms.
    98 
    9996Formset validation
    10097------------------
    10198
  • docs/topics/forms/modelforms.txt

    diff -r b126ac58b50a docs/topics/forms/modelforms.txt
    a b  
    661661
    662662.. versionchanged:: 1.2
    663663
    664 As with regular formsets, you can use the ``max_num`` parameter to
    665 ``modelformset_factory`` to limit the number of extra forms displayed.
     664As with regular formsets, you can use the ``max_num`` and ``extra`` parameters
     665to ``modelformset_factory`` to limit the number of extra forms displayed.
    666666
    667667``max_num`` does not prevent existing objects from being displayed::
    668668
  • tests/modeltests/model_formsets/models.py

    diff -r b126ac58b50a tests/modeltests/model_formsets/models.py
    a b  
    368368
    369369>>> AuthorFormSet = modelformset_factory(Author, max_num=None, extra=3)
    370370>>> formset = AuthorFormSet(queryset=qs)
     371>>> len(formset.forms)
     3726
    371373>>> len(formset.extra_forms)
    3723743
    373375
    374376>>> AuthorFormSet = modelformset_factory(Author, max_num=4, extra=3)
    375377>>> formset = AuthorFormSet(queryset=qs)
     378>>> len(formset.forms)
     3794
    376380>>> len(formset.extra_forms)
    3773811
    378382
    379383>>> AuthorFormSet = modelformset_factory(Author, max_num=0, extra=3)
    380384>>> formset = AuthorFormSet(queryset=qs)
     385>>> len(formset.forms)
     3863
    381387>>> len(formset.extra_forms)
    3823880
    383389
  • tests/regressiontests/forms/formsets.py

    diff -r b126ac58b50a tests/regressiontests/forms/formsets.py
    a b  
    599599
    600600# Base case for max_num.
    601601
     602# When not passed, max_num will take its default value of None, i.e. unlimited
     603# number of forms, only controlled by the value of the extra parameter.
     604
     605>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=3)
     606>>> formset = LimitedFavoriteDrinkFormSet()
     607>>> for form in formset.forms:
     608...     print form
     609<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" id="id_form-0-name" /></td></tr>
     610<tr><th><label for="id_form-1-name">Name:</label></th><td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>
     611<tr><th><label for="id_form-2-name">Name:</label></th><td><input type="text" name="form-2-name" id="id_form-2-name" /></td></tr>
     612
     613# If max_num is 0 then no form is rendered at all.
     614
     615>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=3, max_num=0)
     616>>> formset = LimitedFavoriteDrinkFormSet()
     617>>> for form in formset.forms:
     618...     print form
     619
    602620>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=5, max_num=2)
    603621>>> formset = LimitedFavoriteDrinkFormSet()
    604622>>> for form in formset.forms:
     
    606624<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" id="id_form-0-name" /></td></tr>
    607625<tr><th><label for="id_form-1-name">Name:</label></th><td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>
    608626
    609 # Ensure the that max_num has no affect when extra is less than max_forms.
     627# Ensure that max_num has no effect when extra is less than max_num.
    610628
    611629>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=1, max_num=2)
    612630>>> formset = LimitedFavoriteDrinkFormSet()
     
    616634
    617635# max_num with initial data
    618636
     637# When not passed, max_num will take its default value of None, i.e. unlimited
     638# number of forms, only controlled by the values of the initial and extra
     639# parameters.
     640
     641>>> initial = [
     642...     {'name': 'Fernet and Coke'},
     643... ]
     644>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=1)
     645>>> formset = LimitedFavoriteDrinkFormSet(initial=initial)
     646>>> for form in formset.forms:
     647...     print form
     648<tr><th><label for="id_form-0-name">Name:</label></th><td><input type="text" name="form-0-name" value="Fernet and Coke" id="id_form-0-name" /></td></tr>
     649<tr><th><label for="id_form-1-name">Name:</label></th><td><input type="text" name="form-1-name" id="id_form-1-name" /></td></tr>
     650
     651# If max_num is 0 then no form is rendered at all, even if extra and initial
     652# are specified.
     653
     654>>> initial = [
     655...     {'name': 'Fernet and Coke'},
     656...     {'name': 'Bloody Mary'},
     657... ]
     658>>> LimitedFavoriteDrinkFormSet = formset_factory(FavoriteDrinkForm, extra=1, max_num=0)
     659>>> formset = LimitedFavoriteDrinkFormSet(initial=initial)
     660>>> for form in formset.forms:
     661...     print form
     662
    619663# More initial forms than max_num will result in only the first max_num of
    620664# them to be displayed with no extra forms.
    621665
Back to Top