mirror of
https://github.com/django-polymorphic/django-polymorphic.git
synced 2025-09-03 19:04:53 +03:00
rename CI workflow to Lint, move all rst repo level doc files (like README) to markdown
This commit is contained in:
parent
1d6f226deb
commit
714c702a12
|
@ -1,4 +1,4 @@
|
||||||
name: CI
|
name: Lint
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
|
@ -1,14 +1,8 @@
|
||||||
Main authors (commit rights to the main repository)
|
# Current Maintainer(s)
|
||||||
===================================================
|
|
||||||
|
|
||||||
* Chris Glass
|
* Brian Kohan
|
||||||
* Diederik van der Boor
|
|
||||||
* Charlie Denton
|
|
||||||
* Jerome Leclanche
|
|
||||||
|
|
||||||
|
## Contributors
|
||||||
Contributors
|
|
||||||
=============
|
|
||||||
|
|
||||||
* Abel Daniel
|
* Abel Daniel
|
||||||
* Adam Chainz
|
* Adam Chainz
|
||||||
|
@ -70,8 +64,10 @@ Contributors
|
||||||
* Vail Gold
|
* Vail Gold
|
||||||
|
|
||||||
|
|
||||||
|
## Former authors / maintainers
|
||||||
Former authors / maintainers
|
|
||||||
============================
|
|
||||||
|
|
||||||
* Bert Constantin 2009/2010 (Original author, disappeared from the internet :( )
|
* Bert Constantin 2009/2010 (Original author, disappeared from the internet :( )
|
||||||
|
* Chris Glass
|
||||||
|
* Diederik van der Boor
|
||||||
|
* Charlie Denton
|
||||||
|
* Jerome Leclanche
|
51
CONTRIBUTING.md
Normal file
51
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
[](https://jazzband.co/)
|
||||||
|
|
||||||
|
This is a [Jazzband](https://jazzband.co) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines).
|
||||||
|
|
||||||
|
Contributions are encouraged! Please use the issue page to submit feature requests or bug reports. Issues with attached PRs will be given priority and have a much higher likelihood of acceptance.
|
||||||
|
|
||||||
|
We are actively seeking additional maintainers. If you're interested, [contact me](https://github.com/bckohan).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Install Just
|
||||||
|
|
||||||
|
We provide a platform independent justfile with recipes for all the development tasks. You should [install just](https://just.systems/man/en/installation.html) if it is not on your system already.
|
||||||
|
|
||||||
|
`[django-polymorphic](https://pypi.python.org/pypi/django-polymorphic)` uses [uv](https://docs.astral.sh/uv) for environment, package, and dependency management. ``just setup`` will install the necessary build tooling if you do not already have it:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
just setup
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Static Analysis
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Running Tests
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
## Versioning
|
||||||
|
|
||||||
|
[django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) strictly adheres to [semantic versioning](https://semver.org).
|
||||||
|
|
||||||
|
## Issuing Releases
|
||||||
|
|
||||||
|
The release workflow is triggered by tag creation. You must have [git tag signing enabled](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits). Our justfile has a release shortcut:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just release x.x.x
|
||||||
|
```
|
||||||
|
|
||||||
|
## Just Recipes
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
```
|
|
@ -1,5 +0,0 @@
|
||||||
.. image:: https://jazzband.co/static/img/jazzband.svg
|
|
||||||
:target: https://jazzband.co/
|
|
||||||
:alt: Jazzband
|
|
||||||
|
|
||||||
This is a `Jazzband <https://jazzband.co>`_ project. By contributing you agree to abide by the `Contributor Code of Conduct <https://jazzband.co/about/conduct>`_ and follow the `guidelines <https://jazzband.co/about/guidelines>`_.
|
|
82
README.md
Normal file
82
README.md
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
# django-polymorphic
|
||||||
|
|
||||||
|
[](https://opensource.org/license/bsd-3-clause)
|
||||||
|
[](https://github.com/astral-sh/ruff)
|
||||||
|
[](https://pypi.python.org/pypi/django-polymorphic/)
|
||||||
|
[](https://pypi.python.org/pypi/django-polymorphic/)
|
||||||
|
[](https://pypi.org/project/django-polymorphic/)
|
||||||
|
[](https://pypi.python.org/pypi/django-polymorphic)
|
||||||
|
[](http://django-polymorphic.readthedocs.io/?badge=latest/)
|
||||||
|
[](https://codecov.io/github/jazzband/django-polymorphic?branch=master)
|
||||||
|
[](https://github.com/jazzband/django-polymorphic/actions/workflows/test.yml?query=branch:main)
|
||||||
|
[](https://github.com/jazzband/django-polymorphic/actions/workflows/lint.yml?query=branch:main)
|
||||||
|
[](https://djangopackages.org/packages/p/django-polymorphic/)
|
||||||
|
[](https://jazzband.co/)
|
||||||
|
|
||||||
|
## Polymorphic Models for Django
|
||||||
|
|
||||||
|
[django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) simplifies using inherited models in [Django](https://djangoproject.com) projects. When a query is made at the base model, the inherited model classes are returned.
|
||||||
|
|
||||||
|
When we store models that inherit from a ``Project`` model...
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
>>> Project.objects.create(topic="Department Party")
|
||||||
|
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
||||||
|
>>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
|
||||||
|
```
|
||||||
|
|
||||||
|
...and want to retrieve all our projects, the subclassed models are returned!
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
>>> Project.objects.all()
|
||||||
|
[ <Project: id 1, topic "Department Party">,
|
||||||
|
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
||||||
|
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
||||||
|
```
|
||||||
|
|
||||||
|
Using vanilla Django, we get the base class objects, which is rarely what we wanted:
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
>>> Project.objects.all()
|
||||||
|
[ <Project: id 1, topic "Department Party">,
|
||||||
|
<Project: id 2, topic "Painting with Tim">,
|
||||||
|
<Project: id 3, topic "Swallow Aerodynamics"> ]
|
||||||
|
```
|
||||||
|
|
||||||
|
This also works when the polymorphic model is accessed via
|
||||||
|
ForeignKeys, ManyToManyFields or OneToOneFields.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Full admin integration.
|
||||||
|
* ORM integration:
|
||||||
|
|
||||||
|
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
||||||
|
* Filtering/ordering of inherited models (``ArtProject___artist``).
|
||||||
|
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
||||||
|
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
||||||
|
* Support for custom user-defined managers.
|
||||||
|
* Uses the minimum amount of queries needed to fetch the inherited models.
|
||||||
|
* Disabling polymorphic behavior when needed.
|
||||||
|
|
||||||
|
|
||||||
|
**Note:** While [django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) makes subclassed models easy to use in Django, we still encourage to use them with caution. Each subclassed model will require Django to perform an ``INNER JOIN`` to fetch the model fields from the database. While taking this in mind, there are valid reasons for using subclassed models. That's what this library is designed for!
|
||||||
|
|
||||||
|
The current release of [django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) supports Django 2.2 - 5.2 on Python 3.9+.
|
||||||
|
|
||||||
|
For more information, see the [documentation at Read the Docs](https://django-polymorphic.readthedocs.io).
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
Install using ``pip``\ ...
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pip install django-polymorphic
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[django-polymorphic](https://pypi.python.org/pypi/django-polymorphic) uses the same license as Django (BSD-like).
|
99
README.rst
99
README.rst
|
@ -1,99 +0,0 @@
|
||||||
.. list-table::
|
|
||||||
:header-rows: 0
|
|
||||||
:widths: auto
|
|
||||||
|
|
||||||
* - .. image:: https://github.com/jazzband/django-polymorphic/actions/workflows/test.yml/badge.svg
|
|
||||||
:target: https://github.com/jazzband/django-polymorphic/actions/workflows/test.yml
|
|
||||||
- .. image:: https://img.shields.io/pypi/v/django-polymorphic.svg
|
|
||||||
:target: https://pypi.python.org/pypi/django-polymorphic/
|
|
||||||
- .. image:: https://img.shields.io/codecov/c/github/jazzband/django-polymorphic/master.svg
|
|
||||||
:target: https://codecov.io/github/jazzband/django-polymorphic?branch=master
|
|
||||||
- .. image:: https://readthedocs.org/projects/django-polymorphic/badge/?version=stable
|
|
||||||
:target: https://django-polymorphic.readthedocs.io/en/stable/
|
|
||||||
- .. image:: https://jazzband.co/static/img/badge.svg
|
|
||||||
:target: https://jazzband.co/
|
|
||||||
:alt: Jazzband
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
When we store models that inherit from a ``Project`` model...
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
>>> Project.objects.create(topic="Department Party")
|
|
||||||
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
|
||||||
>>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
|
|
||||||
|
|
||||||
...and want to retrieve all our projects, the subclassed models are returned!
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
>>> Project.objects.all()
|
|
||||||
[ <Project: id 1, topic "Department Party">,
|
|
||||||
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
|
||||||
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
|
||||||
|
|
||||||
Using vanilla Django, we get the base class objects, which is rarely what we wanted:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
>>> Project.objects.all()
|
|
||||||
[ <Project: id 1, topic "Department Party">,
|
|
||||||
<Project: id 2, topic "Painting with Tim">,
|
|
||||||
<Project: id 3, topic "Swallow Aerodynamics"> ]
|
|
||||||
|
|
||||||
This also works when the polymorphic model is accessed via
|
|
||||||
ForeignKeys, ManyToManyFields or OneToOneFields.
|
|
||||||
|
|
||||||
Features
|
|
||||||
--------
|
|
||||||
|
|
||||||
* Full admin integration.
|
|
||||||
* ORM integration:
|
|
||||||
|
|
||||||
* support for ForeignKey, ManyToManyField, OneToOneField descriptors.
|
|
||||||
* Filtering/ordering of inherited models (``ArtProject___artist``).
|
|
||||||
* Filtering model types: ``instance_of(...)`` and ``not_instance_of(...)``
|
|
||||||
* Combining querysets of different models (``qs3 = qs1 | qs2``)
|
|
||||||
* Support for custom user-defined managers.
|
|
||||||
* Uses the minimum amount of queries needed to fetch the inherited models.
|
|
||||||
* Disabling polymorphic behavior when needed.
|
|
||||||
|
|
||||||
|
|
||||||
**Note:** While *django-polymorphic* makes subclassed models easy to use in Django,
|
|
||||||
we still encourage to use them with caution. Each subclassed model will require
|
|
||||||
Django to perform an ``INNER JOIN`` to fetch the model fields from the database.
|
|
||||||
While taking this in mind, there are valid reasons for using subclassed models.
|
|
||||||
That's what this library is designed for!
|
|
||||||
|
|
||||||
The current release of *django-polymorphic* supports Django 2.2 - 4.0 on Python 3.6+.
|
|
||||||
|
|
||||||
For more information, see the `documentation at Read the Docs <https://django-polymorphic.readthedocs.io/>`_.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
Install using ``pip``\ ...
|
|
||||||
|
|
||||||
.. code:: bash
|
|
||||||
|
|
||||||
$ pip install django-polymorphic
|
|
||||||
|
|
||||||
|
|
||||||
At the moment we have an unoffical version (4.0.0a). While we wait to gain access to pip. If you want to use the latest version (which works for Django >4.0.0). You can install it using
|
|
||||||
|
|
||||||
.. code:: bash
|
|
||||||
|
|
||||||
pip install git+https://github.com/jazzband/django-polymorphic.git@v4.0.0a#egg=django-polymorphic
|
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
Django-polymorphic uses the same license as Django (BSD-like).
|
|
|
@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
||||||
name = "django-polymorphic"
|
name = "django-polymorphic"
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
description = "Seamless polymorphic inheritance for Django models."
|
description = "Seamless polymorphic inheritance for Django models."
|
||||||
readme = "README.rst"
|
readme = "README.md"
|
||||||
license = "BSD-3-Clause"
|
license = "BSD-3-Clause"
|
||||||
license-files = [ "LICENSE" ]
|
license-files = [ "LICENSE" ]
|
||||||
requires-python = ">=3.9,<4.0"
|
requires-python = ">=3.9,<4.0"
|
||||||
|
@ -62,7 +62,7 @@ dependencies = [
|
||||||
"Repository" = "https://github.com/jazzband/django-polymorphic"
|
"Repository" = "https://github.com/jazzband/django-polymorphic"
|
||||||
"Issues" = "https://github.com/jazzband/django-polymorphic/issues"
|
"Issues" = "https://github.com/jazzband/django-polymorphic/issues"
|
||||||
"Changelog" = "https://django-polymorphic.readthedocs.io/en/stable/changelog.html"
|
"Changelog" = "https://django-polymorphic.readthedocs.io/en/stable/changelog.html"
|
||||||
"Code_of_Conduct" = "https://github.com/django-commons/membership/blob/main/CODE_OF_CONDUCT.md"
|
"Code_of_Conduct" = "https://jazzband.co/about/conduct"
|
||||||
|
|
||||||
[tool.uv]
|
[tool.uv]
|
||||||
package = true
|
package = true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user