Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
ca73670
Bump django from 3.2.9 to 3.2.18 in /docs/_ext/djangodummy
dependabot[bot] Feb 15, 2023
e0dec44
Update advanced.rst
pfcodes Nov 28, 2022
3e830a3
Removed usage of deprecated pkg_resources (#541)
sliverc Nov 17, 2023
f2138b3
docs: fix missing whitespace (#519)
JanMalte Nov 17, 2023
b1dcd3e
Add css dark mode to polymorphic_inlines.css
namantam1 Feb 11, 2022
b2d3ab7
Bump django from 3.2.18 to 3.2.23 in /docs/_ext/djangodummy
dependabot[bot] Nov 17, 2023
bd2ff0b
Fix multi-fields in single line
morsik Apr 8, 2023
be374e2
Fix for broken fix about multi-fields in single line
morsik Nov 18, 2023
0acc648
Add contributing doc and badge
AdamDonna Nov 23, 2023
39e1adf
Precommit
AdamDonna Nov 23, 2023
9553e52
Fix files
AdamDonna Nov 23, 2023
38689ac
Apply suggestions from code review
AdamDonna Nov 23, 2023
57b2d17
Ignore migrations
AdamDonna Nov 23, 2023
b1a26e8
More formatting
AdamDonna Nov 23, 2023
39d0985
Fix all links in the docs
AdamDonna Nov 23, 2023
564284e
Merge pull request #559 from jazzband/update-doc-links
j-antunes Nov 27, 2023
1a5f26d
Merge pull request #557 from jazzband/add-pre-commit
j-antunes Nov 27, 2023
0ead3b6
Replace Travis CI configuration with GitHub Actions (#561)
akx Dec 12, 2023
4a36247
Lint and format with ruff (#560)
akx Dec 16, 2023
9d674e4
Drop support for non-supported versions of Django and Python (#563)
akx Dec 18, 2023
30fad7b
Use py.test for testing
akx Dec 12, 2023
4d4a08a
Use plain assertions where possible
akx Dec 12, 2023
63d291f
Modernize spelling for assertQuerySetEqual
akx Dec 12, 2023
6e461ca
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 18, 2023
d6b507f
Merge pull request #564 from jazzband/pre-commit-ci-update-config
j-antunes Dec 20, 2023
4240931
Merge pull request #562 from akx/improve-testing
j-antunes Dec 20, 2023
92400f1
Use default coverage file locations
hugovk Dec 20, 2023
b3b2db1
pytest: drop the dot
hugovk Dec 20, 2023
9a8daee
Replace string interpolation and .format calls with f-strings
akx Dec 20, 2023
bd18ac5
Remove unnecessary Django version checks
akx Dec 20, 2023
8ea4932
Remove unnecessary Python version compatibility bits
akx Dec 20, 2023
71d70af
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 25, 2023
b8a9b11
Merge pull request #568 from jazzband/pre-commit-ci-update-config
j-antunes Dec 30, 2023
836a445
Merge pull request #566 from akx/modernize-f-strings
j-antunes Dec 30, 2023
f188df0
Merge pull request #567 from akx/version-checks
j-antunes Dec 30, 2023
961ba6c
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jan 8, 2024
390261f
Merge pull request #569 from jazzband/pre-commit-ci-update-config
j-antunes Jan 14, 2024
51a0c79
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jan 22, 2024
a0bd0b3
Merge pull request #571 from jazzband/pre-commit-ci-update-config
j-antunes Jan 22, 2024
35e6ee4
Merge pull request #565 from hugovk/fix-coverage
j-antunes Jan 31, 2024
6e92da7
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Feb 5, 2024
30e10e8
Merge pull request #574 from jazzband/pre-commit-ci-update-config
j-antunes Feb 7, 2024
5108f00
Bump django from 3.2.23 to 3.2.24 in /docs/_ext/djangodummy
dependabot[bot] Feb 7, 2024
fa6bc9f
Merge pull request #575 from jazzband/dependabot/pip/docs/_ext/django…
j-antunes Feb 12, 2024
40f99c3
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Feb 19, 2024
6fdab04
Merge pull request #577 from jazzband/pre-commit-ci-update-config
j-antunes Feb 21, 2024
ae9bc80
chore: cleanup
CodeWithEmad Mar 1, 2024
f4286f5
Merge pull request #584 from CodeWithEmad/chore/cleanup
j-antunes Mar 1, 2024
bba4b41
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Mar 12, 2024
9b60339
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 12, 2024
72be860
Merge pull request #585 from jazzband/pre-commit-ci-update-config
j-antunes Mar 18, 2024
ea665d7
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Mar 18, 2024
921ce14
Bump django from 3.2.24 to 3.2.25 in /docs/_ext/djangodummy
dependabot[bot] Mar 18, 2024
989b2c6
Merge pull request #586 from jazzband/pre-commit-ci-update-config
j-antunes Mar 21, 2024
3312f5f
Merge pull request #587 from jazzband/dependabot/pip/docs/_ext/django…
j-antunes Mar 21, 2024
cdfd457
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Mar 25, 2024
bc932cc
Merge pull request #588 from jazzband/pre-commit-ci-update-config
j-antunes Mar 27, 2024
1a9fe8a
Fix build read the docs
Smurf2-pluto Apr 3, 2024
d076ef5
Merge pull request #589 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
0bd4c95
Fix build read the docs. Second attempt
Smurf2-pluto Apr 3, 2024
6fee9b4
Merge pull request #590 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
8b202f5
Fix build read the docs. Third attempt
Smurf2-pluto Apr 3, 2024
d70f7b8
Merge pull request #591 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
186f28d
Fix build read the docs. 4th attempt
Smurf2-pluto Apr 3, 2024
f74e07e
Merge pull request #592 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
93a5d59
Fix build read the docs. 5th attempt
Smurf2-pluto Apr 3, 2024
a361b6c
Merge pull request #593 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
6274916
Fix build read the docs. 6th attempt
Smurf2-pluto Apr 3, 2024
2d01436
Merge pull request #594 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
eb24017
Fix build read the docs. 7th attempt
Smurf2-pluto Apr 3, 2024
8510347
Merge pull request #595 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
b20fd4d
Fix build read the docs. 8th attempt
Smurf2-pluto Apr 3, 2024
3cf751d
Merge pull request #596 from jazzband/fix/fix_docs.ja
j-antunes Apr 3, 2024
9355c63
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Apr 15, 2024
423cbab
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 15, 2024
5881b36
Merge pull request #597 from jazzband/pre-commit-ci-update-config
j-antunes Apr 16, 2024
830111d
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Apr 22, 2024
bcb514d
Merge pull request #600 from jazzband/pre-commit-ci-update-config
j-antunes Apr 25, 2024
80d7ca1
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Apr 29, 2024
97cd1e2
Merge pull request #601 from jazzband/pre-commit-ci-update-config
j-antunes May 3, 2024
a892318
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] May 6, 2024
2d7f691
Merge pull request #602 from jazzband/pre-commit-ci-update-config
j-antunes May 12, 2024
52815f3
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] May 13, 2024
ae3e7d6
Merge pull request #603 from jazzband/pre-commit-ci-update-config
j-antunes May 17, 2024
0cd2cde
Update README.rst
j-antunes May 19, 2024
194c1b6
Update README.rst
j-antunes May 19, 2024
2cf9b5c
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] May 27, 2024
16c61ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 27, 2024
5520c8c
Merge pull request #604 from jazzband/pre-commit-ci-update-config
PetrDlouhy May 29, 2024
5eb2538
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jun 3, 2024
77e32f4
Merge pull request #605 from jazzband/pre-commit-ci-update-config
j-antunes Jun 4, 2024
371f6cd
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jun 10, 2024
fd9d075
Update README.rst
boxed Jun 11, 2024
5250cd5
Merge pull request #607 from boxed/patch-1
j-antunes Jun 12, 2024
cfd49b2
Merge pull request #606 from jazzband/pre-commit-ci-update-config
j-antunes Jun 12, 2024
3ba02c9
Merge commit 'cfd49b26d580d99b00dcd43a02409ce439a2c78f' into v4
Smona Sep 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: pre-commit/[email protected]
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
branches:
- master
tags:
- '*'

jobs:
Build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3"
cache: pip
cache-dependency-path: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
- run: pip install -U build
- run: python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test
on:
- pull_request
- push
- workflow_dispatch
jobs:
Build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3"
cache: pip
cache-dependency-path: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
- run: pip install -U build
- run: python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
Test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- python-version: "3.8"
- python-version: "3.9"
- python-version: "3.10"
- python-version: "3.11"
- python-version: "3.12"
steps:
- uses: actions/checkout@v4
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: pip
cache-dependency-path: setup.cfg
# TODO: look into using python-babel instead of requiring gettext as system dependency
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gettext
# TODO: look into using python-babel instead of requiring django to be ambiently installed
# so tox can build messages
- run: pip install -U tox tox-gh-actions django
# TODO: postgres setup and proper djangomain testing
- run: python -m tox
- uses: codecov/codecov-action@v3
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
exclude: '.*migrations.*'
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/_ext/djangodummy/requirements.txt
62 changes: 0 additions & 62 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Contributors
* Chris Brantley
* Christopher Glass
* David Sanders
* Emad Rad
* Éric Araujo
* Evan Borgstrom
* Frankie Dintino
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. 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>`_.
35 changes: 26 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
.. image:: https://travis-ci.org/django-polymorphic/django-polymorphic.svg?branch=master
:target: http://travis-ci.org/django-polymorphic/django-polymorphic
.. 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/django-polymorphic/django-polymorphic/master.svg
:target: https://codecov.io/github/django-polymorphic/django-polymorphic?branch=master
.. image:: https://readthedocs.org/projects/django-polymorphic/badge/?version=stable
:target: https://django-polymorphic.readthedocs.io/en/stable/
.. 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
=============================
Expand Down Expand Up @@ -53,7 +62,7 @@ Features
* 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 minumum amount of queries needed to fetch the inherited models.
* Uses the minimum amount of queries needed to fetch the inherited models.
* Disabling polymorphic behavior when needed.


Expand All @@ -76,6 +85,14 @@ Install using ``pip``\ ...

$ 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/[email protected]#egg=django-polymorphic


License
=======

Expand Down
3 changes: 2 additions & 1 deletion docs/_ext/djangodummy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# for readthedocs
# Remaining requirements are picked up from setup.py
Django == 3.2.9
Django == 3.2.25
django-extra-views == 0.14.0
sphinxcontrib-django == 0.5.1
sphinx_rtd_theme==2.0.0
2 changes: 1 addition & 1 deletion docs/admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ This class implements the following features:
* It allows to set :attr:`~polymorphic.admin.PolymorphicChildModelAdmin.base_form` so the derived class will automatically include other fields in the form.
* It allows to set :attr:`~polymorphic.admin.PolymorphicChildModelAdmin.base_fieldsets` so the derived class will automatically display any extra fields.
* Although it must be registered with admin site, by default it's hidden from admin site index page.
This can be overriden by adding :attr:`~polymorphic.admin.PolymorphicChildModelAdmin.show_in_index` = ``True`` in admin class.
This can be overridden by adding :attr:`~polymorphic.admin.PolymorphicChildModelAdmin.show_in_index` = ``True`` in admin class.


.. _django-reversion: https://github.com/etianen/django-reversion
Expand Down
11 changes: 5 additions & 6 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ If you insert ``.non_polymorphic()`` anywhere into the query chain, then
django_polymorphic will simply leave out the final step of retrieving the
real objects, and the manager/queryset will return objects of the type of
the base class you used for the query, like vanilla Django would
(``ModelA`` in this example).
(``ModelA`` in this example).

>>> qs=ModelA.objects.non_polymorphic().all()
>>> qs
Expand Down Expand Up @@ -183,12 +183,12 @@ About Queryset Methods
queryset or list of base model objects efficiently into the real objects.
For example, you could do ``base_objects_queryset=ModelA.extra(...).non_polymorphic()``
and then call ``real_objects=base_objects_queryset.get_real_instances()``. Or alternatively
.``real_objects=ModelA.objects.get_real_instances(base_objects_queryset_or_object_list)``
``real_objects=ModelA.objects.get_real_instances(base_objects_queryset_or_object_list)``

* ``values()`` & ``values_list()`` currently do not return polymorphic
results. This may change in the future however. If you want to use these
methods now, it's best if you use ``Model.base_objects.values...`` as
this is guaranteed to not change.
this is guaranteed to not change.

* ``defer()`` and ``only()`` work as expected. On Django 1.5+ they support
the ``ModelX___field`` syntax, but on Django 1.4 it is only possible to
Expand Down Expand Up @@ -252,7 +252,7 @@ Restrictions & Caveats
the resulting objects are required to have a unique primary key within
the result set.

* Diamond shaped inheritance: There seems to be a general problem
* Diamond shaped inheritance: There seems to be a general problem
with diamond shaped multiple model inheritance with Django models
(tested with V1.1 - V1.3).
An example is here: http://code.djangoproject.com/ticket/10808.
Expand All @@ -267,7 +267,7 @@ Restrictions & Caveats
* When using the ``dumpdata`` management command on polymorphic tables
(or any table that has a reference to
:class:`~django.contrib.contenttypes.models.ContentType`),
include the ``--natural`` flag in the arguments.
include the ``--natural-foreign`` and ``--natural-primary`` flags in the arguments.



Expand All @@ -288,4 +288,3 @@ Restrictions & Caveats
- http://groups.google.com/group/django-users/browse_thread/thread/52f72cffebb705e/bc18c18b2e83881e?lnk=gst&q=model+inheritance#bc18c18b2e83881e
- http://code.djangoproject.com/ticket/10808
- http://code.djangoproject.com/ticket/7270

1 change: 0 additions & 1 deletion docs/api/polymorphic.admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,3 @@ These classes are useful when existing parts of the admin classes.

.. autoclass:: polymorphic.admin.PolymorphicInlineAdminFormSet
:show-inheritance:

6 changes: 2 additions & 4 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributing

You can contribute to *django-polymorphic* to forking the code on GitHub:

https://github.com/django-polymorphic/django-polymorphic
https://github.com/jazzband/django-polymorphic


Running tests
Expand All @@ -13,7 +13,7 @@ We require features to be backed by a unit test.
This way, we can test *django-polymorphic* against new Django versions.
To run the included test suite, execute::

./runtests.py
pytest

To test support for multiple Python and Django versions, run tox from the repository root::

Expand All @@ -24,8 +24,6 @@ The Python versions need to be installed at your system.
On Linux, download the versions at http://www.python.org/download/releases/.
On MacOS X, use Homebrew_ to install other Python versions.

We currently support Python 3.5, 3.6, 3.7, and 3.8.


Example project
----------------
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

2 changes: 1 addition & 1 deletion example/example/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from django.urls import include, path, reverse_lazy
from django.urls import path, reverse_lazy
from django.views.generic import RedirectView

admin.autodiscover()
Expand Down
1 change: 1 addition & 0 deletions example/example/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.

"""

import os

# This application object is used by any WSGI server configured to use this
Expand Down
Loading
Loading