Mention the word "inherited models" in the docs more often
..to give some SEO juice to the project because developers are looking for "inherited models" instead of "polymorphism".fix_request_path_info
parent
c933be9c24
commit
93a6592649
11
README.rst
11
README.rst
|
|
@ -1,11 +1,14 @@
|
||||||
Polymorphic Models for Django
|
Polymorphic Models for Django
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
Django-polymorphic simplifies using inherited models in Django projects.
|
||||||
|
When a query is made at the base model, the inherited model classes are returned!
|
||||||
|
|
||||||
What is django_polymorphic good for?
|
What is django_polymorphic good for?
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
Let's assume the models ``ArtProject`` and ``ResearchProject`` are derived
|
Let's take the models ``ArtProject`` and ``ResearchProject`` which inherit
|
||||||
from the model ``Project``, and stored in the database:
|
from the model ``Project``, and store them in the database:
|
||||||
|
|
||||||
>>> Project.objects.create(topic="Department Party")
|
>>> Project.objects.create(topic="Department Party")
|
||||||
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
||||||
|
|
@ -37,12 +40,12 @@ Features
|
||||||
* ORM integration:
|
* ORM integration:
|
||||||
|
|
||||||
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
||||||
* Filtering/ordering of derived models (``ArtProject___artist``).
|
* Filtering/ordering of inherited models (``ArtProject___artist``).
|
||||||
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
||||||
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
||||||
* Support for custom user-defined managers.
|
* Support for custom user-defined managers.
|
||||||
|
|
||||||
* Uses the minumum amount of queries needed to fetch the derived models.
|
* Uses the minumum amount of queries needed to fetch the inherited models.
|
||||||
* Disabling polymorphic behavior when needed.
|
* Disabling polymorphic behavior when needed.
|
||||||
|
|
||||||
While *django-polymorphic* makes subclassed models easy to use in Django,
|
While *django-polymorphic* makes subclassed models easy to use in Django,
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ You can also use this feature in Q-objects (with the same result as above):
|
||||||
>>> ModelA.objects.filter( Q(instance_of=ModelB) )
|
>>> ModelA.objects.filter( Q(instance_of=ModelB) )
|
||||||
|
|
||||||
|
|
||||||
Polymorphic filtering (for fields in derived classes)
|
Polymorphic filtering (for fields in inherited classes)
|
||||||
-----------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
|
||||||
For example, cherrypicking objects from multiple derived classes
|
For example, cherrypicking objects from multiple derived classes
|
||||||
anywhere in the inheritance tree, using Q objects (with the
|
anywhere in the inheritance tree, using Q objects (with the
|
||||||
|
|
@ -151,7 +151,7 @@ About Queryset Methods
|
||||||
the base class, but this should never make a difference.
|
the base class, but this should never make a difference.
|
||||||
|
|
||||||
* ``select_related()`` works just as usual, but it can not (yet) be used
|
* ``select_related()`` works just as usual, but it can not (yet) be used
|
||||||
to select relations in derived models
|
to select relations in inherited models
|
||||||
(like ``ModelA.objects.select_related('ModelC___fieldxy')`` )
|
(like ``ModelA.objects.select_related('ModelC___fieldxy')`` )
|
||||||
|
|
||||||
* ``extra()`` works as expected (it returns polymorphic results) but
|
* ``extra()`` works as expected (it returns polymorphic results) but
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ Bugfixes
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
* Custom fields could cause problems when used as the primary key.
|
* Custom fields could cause problems when used as the primary key.
|
||||||
In derived models, Django's automatic ".pk" field does not always work
|
In inherited models, Django's automatic ".pk" field does not always work
|
||||||
correctly for such custom fields: "some_object.pk" and "some_object.id"
|
correctly for such custom fields: "some_object.pk" and "some_object.id"
|
||||||
return different results (which they shouldn't, as pk should always be just
|
return different results (which they shouldn't, as pk should always be just
|
||||||
an alias for the primary key field). It's unclear yet if the problem lies in
|
an alias for the primary key field). It's unclear yet if the problem lies in
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ Welcome to django-polymorphic's documentation!
|
||||||
Django-polymorphic simplifies using inherited models in Django projects.
|
Django-polymorphic simplifies using inherited models in Django projects.
|
||||||
When a query is made at the base model, the inherited model classes are returned.
|
When a query is made at the base model, the inherited model classes are returned.
|
||||||
|
|
||||||
When we store models that derive from a ``Project`` model...
|
When we store models that inherit from a ``Project`` model...
|
||||||
|
|
||||||
>>> Project.objects.create(topic="Department Party")
|
>>> Project.objects.create(topic="Department Party")
|
||||||
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
||||||
|
|
@ -32,12 +32,12 @@ Features
|
||||||
|
|
||||||
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
||||||
* support for proxy models
|
* support for proxy models
|
||||||
* Filtering/ordering of derived models (``ArtProject___artist``).
|
* Filtering/ordering of inherited models (``ArtProject___artist``).
|
||||||
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
||||||
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
||||||
* Support for custom user-defined managers.
|
* Support for custom user-defined managers.
|
||||||
|
|
||||||
* Uses the minumum amount of queries needed to fetch the derived models.
|
* Uses the minumum amount of queries needed to fetch the inherited models.
|
||||||
* Disabling polymorphic behavior when needed.
|
* Disabling polymorphic behavior when needed.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue