Debian Codegraph @

docs/index.rst

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 django-polymorphic
2 ==================
3
4 .. only:: html
5
6 .. image:: https://img.shields.io/badge/License-BSD-blue.svg
7 :target: https://opensource.org/license/bsd-3-clause
8 :alt: License: BSD
9
10 .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
11 :target: https://github.com/astral-sh/ruff
12 :alt: Ruff
13
14 .. image:: https://badge.fury.io/py/django-polymorphic.svg
15 :target: https://pypi.python.org/pypi/django-polymorphic/
16 :alt: PyPI version
17
18 .. image:: https://img.shields.io/pypi/pyversions/django-polymorphic.svg
19 :target: https://pypi.python.org/pypi/django-polymorphic/
20 :alt: PyPI pyversions
21
22 .. image:: https://img.shields.io/pypi/djversions/django-polymorphic.svg
23 :target: https://pypi.org/project/django-polymorphic/
24 :alt: PyPI Django versions
25
26 .. image:: https://img.shields.io/pypi/status/django-polymorphic.svg
27 :target: https://pypi.python.org/pypi/django-polymorphic
28 :alt: PyPI status
29
30 .. image:: https://img.shields.io/pypi/types/django-polymorphic.svg
31 :target: https://pypi.python.org/pypi/django-polymorphic
32 :alt: PyPi Typed
33
34 .. image:: https://readthedocs.org/projects/django-polymorphic/badge/?version=latest
35 :target: http://django-polymorphic.readthedocs.io/?badge=latest/
36 :alt: Documentation Status
37
38 .. image:: https://img.shields.io/codecov/c/github/django-commons/django-polymorphic/main.svg
39 :target: https://codecov.io/github/django-commons/django-polymorphic?branch=main
40 :alt: Code Coverage
41
42 .. image:: https://github.com/django-commons/django-polymorphic/actions/workflows/test.yml/badge.svg?branch=main
43 :target: https://github.com/django-commons/django-polymorphic/actions/workflows/test.yml?query=branch:main
44 :alt: Test Status
45
46 .. image:: https://github.com/django-commons/django-polymorphic/actions/workflows/lint.yml/badge.svg?branch=main
47 :target: https://github.com/django-commons/django-polymorphic/actions/workflows/lint.yml?query=branch:main
48 :alt: Lint Status
49
50 .. image:: https://img.shields.io/badge/Published%20on-Django%20Packages-0c3c26
51 :target: https://djangopackages.org/packages/p/django-polymorphic/
52 :alt: Published on Django Packages
53
54
55 :pypi:`django-polymorphic` builds on top of the standard Django model inheritance.
56 It makes using inherited models easier. When a query is made at the base model,
57 the inherited model classes are returned.
58
59 When we store models that inherit from a ``Project`` model...
60
61 .. code-block:: python
62
63 >>> Project.objects.create(topic="Department Party")
64 >>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
65 >>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
66
67 ...and want to retrieve all our projects, the subclassed models are returned!
68
69 .. code-block:: python
70
71 >>> Project.objects.all()
72 [ <Project: id 1, topic "Department Party">,
73 <ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
74 <ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
75
76 Using vanilla Django, we get the base class objects, which is rarely what we wanted:
77
78 .. code-block:: python
79
80 >>> Project.objects.all()
81 [ <Project: id 1, topic "Department Party">,
82 <Project: id 2, topic "Painting with Tim">,
83 <Project: id 3, topic "Swallow Aerodynamics"> ]
84
85 Features
86 --------
87
88 * Full admin integration.
89 * ORM integration:
90
91 - Support for ForeignKey, ManyToManyField, OneToOneField descriptors.
92 - Support for proxy models.
93 - Filtering/ordering of inherited models (``ArtProject___artist``).
94 - Filtering model types: :meth:`~polymorphic.managers.PolymorphicQuerySet.instance_of` and
95 :meth:`~polymorphic.managers.PolymorphicQuerySet.not_instance_of`
96 - Combining querysets of different models (``qs3 = qs1 | qs2``)
97 - Support for custom user-defined managers.
98
99 * Formset support.
100 * Uses the minimum amount of queries needed to fetch the inherited models.
101 * Disabling polymorphic behavior when needed.
102
103
104 Getting started
105 ---------------
106
107 .. toctree::
108 :maxdepth: 2
109
110 quickstart
111 admin
112 performance
113 integrations/index
114
115 Advanced topics
116 ---------------
117
118 .. toctree::
119 :maxdepth: 2
120
121 formsets
122 views
123 migrating
124 managers
125 deletion
126 typing
127 advanced
128 changelog/index
129 api/index
130
131
132 Indices and tables
133 ==================
134
135 * :ref:`genindex`
136 * :ref:`modindex`
137 * :ref:`search`