Doc fixes taken from PR #59
parent
2a599b5f99
commit
b75e55b6f1
|
|
@ -34,6 +34,8 @@ the performance hit of retrieving child models.
|
||||||
This can be controlled by setting the ``polymorphic_list`` property on the
|
This can be controlled by setting the ``polymorphic_list`` property on the
|
||||||
parent admin. Setting it to True will provide child models to the list template.
|
parent admin. Setting it to True will provide child models to the list template.
|
||||||
|
|
||||||
|
If you use other applications such as django-reversion_ or django-mptt_, please check +:ref:`third-party`.
|
||||||
|
|
||||||
Note: If you are using non-integer primary keys in your model, you have to edit ``pk_regex``,
|
Note: If you are using non-integer primary keys in your model, you have to edit ``pk_regex``,
|
||||||
for example ``pk_regex = '([\w-]+)'`` if you use UUIDs. Otherwise you cannot change model entries.
|
for example ``pk_regex = '([\w-]+)'`` if you use UUIDs. Otherwise you cannot change model entries.
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ The models are taken from :ref:`advanced-features`.
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter
|
||||||
from .models import ModelA, ModelB, ModelC, StandardModel
|
from .models import ModelA, ModelB, ModelC, StandardModel
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -104,6 +106,7 @@ The models are taken from :ref:`advanced-features`.
|
||||||
""" The parent model admin """
|
""" The parent model admin """
|
||||||
base_model = ModelA
|
base_model = ModelA
|
||||||
child_models = (ModelB, ModelC)
|
child_models = (ModelB, ModelC)
|
||||||
|
list_filter = (PolymorphicChildModelFilter,) # This is optional.
|
||||||
|
|
||||||
|
|
||||||
class ModelBInline(admin.StackedInline):
|
class ModelBInline(admin.StackedInline):
|
||||||
|
|
@ -121,3 +124,13 @@ The models are taken from :ref:`advanced-features`.
|
||||||
admin.site.register(ModelB, ModelBAdmin)
|
admin.site.register(ModelB, ModelBAdmin)
|
||||||
admin.site.register(ModelC, ModelCAdmin)
|
admin.site.register(ModelC, ModelCAdmin)
|
||||||
admin.site.register(StandardModel, StandardModelAdmin)
|
admin.site.register(StandardModel, StandardModelAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
Filtering child types
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Child model types can be filtered by adding a :class:`~polymorphic.admin.PolymorphicChildModelFilter`
|
||||||
|
to the ``list_filter`` attribute. See the example above.
|
||||||
|
|
||||||
|
.. _django-reversion: https://github.com/etianen/django-reversion
|
||||||
|
.. _django-mptt: https://github.com/django-mptt/django-mptt
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ However, they require more setup than standard models. That's become:
|
||||||
Example
|
Example
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
The admin :ref:`admin-example` becomes:
|
The admin :ref:`admin example <admin-example>` becomes:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue