From b75e55b6f172aa32fda6481434681ae0450c82cb Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Mon, 13 Jun 2016 10:31:30 +0200 Subject: [PATCH] Doc fixes taken from PR #59 --- docs/admin.rst | 15 ++++++++++++++- docs/third-party.rst | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/admin.rst b/docs/admin.rst index 3a945f5..60885bb 100644 --- a/docs/admin.rst +++ b/docs/admin.rst @@ -34,6 +34,8 @@ the performance hit of retrieving child models. 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. +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``, 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 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 @@ -104,6 +106,7 @@ The models are taken from :ref:`advanced-features`. """ The parent model admin """ base_model = ModelA child_models = (ModelB, ModelC) + list_filter = (PolymorphicChildModelFilter,) # This is optional. class ModelBInline(admin.StackedInline): @@ -121,3 +124,13 @@ The models are taken from :ref:`advanced-features`. admin.site.register(ModelB, ModelBAdmin) admin.site.register(ModelC, ModelCAdmin) 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 diff --git a/docs/third-party.rst b/docs/third-party.rst index 1bac44b..d43e816 100644 --- a/docs/third-party.rst +++ b/docs/third-party.rst @@ -18,7 +18,7 @@ However, they require more setup than standard models. That's become: Example ~~~~~~~ -The admin :ref:`admin-example` becomes: +The admin :ref:`admin example ` becomes: .. code-block:: python