docs start for formset/inline support

This commit is contained in:
Diederik van der Boor
2016-06-13 10:18:18 +02:00
parent a07ce7260c
commit 8c42893abd
8 changed files with 48 additions and 9 deletions
+5 -3
View File
@@ -57,10 +57,12 @@ use the ``base_form`` and ``base_fieldsets`` instead. The ``PolymorphicChildMode
automatically detect the additional fields that the child model has, display those in a separate fieldset.
Polymorphic Inlines
-------------------
Using polymorphic models in standard inlines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To add a polymorphic child model as an Inline for another model, add a field to the inline's readonly_fields list formed by the lowercased name of the polymorphic parent model with the string "_ptr" appended to it. Otherwise, trying to save that model in the admin will raise an AttributeError with the message "can't set attribute".
To add a polymorphic child model as an Inline for another model, add a field to the inline's ``readonly_fields`` list
formed by the lowercased name of the polymorphic parent model with the string ``_ptr`` appended to it.
Otherwise, trying to save that model in the admin will raise an AttributeError with the message "can't set attribute".
.. _admin-example:
+12
View File
@@ -0,0 +1,12 @@
Formsets
========
Polymorphic models can be used in formsets.
Use the :func:`polymorphic.formsets.polymorphic_inlineformset_factory` function to generate the formset.
As extra parameter, the factory needs to know how to display the child models.
Provide a list of :class:`polymorphic.formsets.PolymorphicFormSetChild` objects for this
.. code-block:: python
from polymorphic.formsets import polymorphic_child_forms_factory
+1
View File
@@ -49,6 +49,7 @@ Getting started
quickstart
admin
formsets
performance
Advanced topics