docs start for formset/inline support
This commit is contained in:
+5
-3
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -49,6 +49,7 @@ Getting started
|
||||
|
||||
quickstart
|
||||
admin
|
||||
formsets
|
||||
performance
|
||||
|
||||
Advanced topics
|
||||
|
||||
Reference in New Issue
Block a user