Name | django-admin-ordering JSON |
Version |
0.19.1
JSON |
| download |
home_page | None |
Summary | Orderable change lists and inlines done right^Wsimple |
upload_time | 2024-11-22 11:49:01 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | BSD-3-Clause |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
==============================================================================
django-admin-ordering -- Orderable change lists and inlines done right^Wsimple
==============================================================================
.. image:: https://github.com/matthiask/django-admin-ordering/actions/workflows/tests.yml/badge.svg
:target: https://github.com/matthiask/django-admin-ordering/
:alt: CI Status
Please refer to the CI build linked above for the currently supported
combinations of Python and Django.
Installation
============
``pip install django-admin-ordering``, and add ``admin_ordering`` to
``INSTALLED_APPS``.
Usage
=====
First, you need a model ordered by an integer field. If you are happy
with a model where 1. the ordering field is called ``ordering`` and 2.
the ordering field is automatically initialized so that new objects are
ordered last you can also inherit the abstract
``admin_ordering.models.OrderableModel`` model. If you define your own ``class
Meta`` you should inherit ``OrderableModel.Meta`` so that the ``ordering``
attribute is set to the correct value:
.. code-block:: python
from admin_ordering.models import OrderableModel
class MyModel(OrderableModel):
# ...
class Meta(OrderableModel.Meta):
# ...
Orderable change lists
~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
from admin_ordering.admin import OrderableAdmin
@admin.register(MyModel)
class MyModelAdmin(OrderableAdmin, admin.ModelAdmin):
# The field used for ordering. Prepend a minus for reverse
# ordering: "-ordering"
# Doesn't have to be provided as long as you're using the default.
# ordering_field = "ordering"
# You may optionally hide the ordering field in the changelist:
# ordering_field_hide_input = False
# The ordering field can optionally be automatically renumbered when
# the page loads. This may be useful if you have existing data which
# isn't ordered yet.
# ordering_field_renumber_on_load = False
# The ordering field must be included both in list_display and
# list_editable:
list_display = ["name", "ordering"]
list_editable = ["ordering"]
Orderable inlines
~~~~~~~~~~~~~~~~~
.. code-block:: python
from admin_ordering.admin import OrderableAdmin
class MyModelTabularInline(OrderableAdmin, admin.TabularInline):
model = MyModel
# Same as above; "-ordering" is also allowed here:
# ordering_field = "ordering"
# ordering_field_hide_input = False
# ordering_field_renumber_on_load = False
``OrderableAdmin`` comes with a default of ``extra = 0`` (no extra
empty inlines shown by default). It is strongly recommended to leave the
changed default as-is, because otherwise you'll end up with invalid
inlines just because you wanted to change the ordering.
Limitations
===========
- ``OrderableAdmin`` can be used both for inlines and parents, but this
also means that you cannot register a model directly with
``OrderableAdmin``.
- Using django-admin-ordering with filtered or paginated lists may
produce unexpected results. The recommendation right now is to set
`list_per_page` to a bigger value and not reordering filtered
changelists.
- Note that django-admin-ordering assigns ordering values in increments
of 10, emphasizing that the ordering value should not have any
significance apart from giving relative ordering to elements.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-admin-ordering",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Matthias Kestenholz <mk@feinheit.ch>",
"download_url": "https://files.pythonhosted.org/packages/57/4c/fa6e95035f6255f6e6a2748ed6a8d097cae58ba129ed8886604407b879d5/django_admin_ordering-0.19.1.tar.gz",
"platform": null,
"description": "==============================================================================\ndjango-admin-ordering -- Orderable change lists and inlines done right^Wsimple\n==============================================================================\n\n.. image:: https://github.com/matthiask/django-admin-ordering/actions/workflows/tests.yml/badge.svg\n :target: https://github.com/matthiask/django-admin-ordering/\n :alt: CI Status\n\nPlease refer to the CI build linked above for the currently supported\ncombinations of Python and Django.\n\n\nInstallation\n============\n\n``pip install django-admin-ordering``, and add ``admin_ordering`` to\n``INSTALLED_APPS``.\n\n\nUsage\n=====\n\nFirst, you need a model ordered by an integer field. If you are happy\nwith a model where 1. the ordering field is called ``ordering`` and 2.\nthe ordering field is automatically initialized so that new objects are\nordered last you can also inherit the abstract\n``admin_ordering.models.OrderableModel`` model. If you define your own ``class\nMeta`` you should inherit ``OrderableModel.Meta`` so that the ``ordering``\nattribute is set to the correct value:\n\n.. code-block:: python\n\n from admin_ordering.models import OrderableModel\n\n class MyModel(OrderableModel):\n # ...\n\n class Meta(OrderableModel.Meta):\n # ...\n\n\nOrderable change lists\n~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from admin_ordering.admin import OrderableAdmin\n\n @admin.register(MyModel)\n class MyModelAdmin(OrderableAdmin, admin.ModelAdmin):\n # The field used for ordering. Prepend a minus for reverse\n # ordering: \"-ordering\"\n # Doesn't have to be provided as long as you're using the default.\n # ordering_field = \"ordering\"\n\n # You may optionally hide the ordering field in the changelist:\n # ordering_field_hide_input = False\n\n # The ordering field can optionally be automatically renumbered when\n # the page loads. This may be useful if you have existing data which\n # isn't ordered yet.\n # ordering_field_renumber_on_load = False\n\n # The ordering field must be included both in list_display and\n # list_editable:\n list_display = [\"name\", \"ordering\"]\n list_editable = [\"ordering\"]\n\n\nOrderable inlines\n~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from admin_ordering.admin import OrderableAdmin\n\n class MyModelTabularInline(OrderableAdmin, admin.TabularInline):\n model = MyModel\n\n # Same as above; \"-ordering\" is also allowed here:\n # ordering_field = \"ordering\"\n # ordering_field_hide_input = False\n # ordering_field_renumber_on_load = False\n\n``OrderableAdmin`` comes with a default of ``extra = 0`` (no extra\nempty inlines shown by default). It is strongly recommended to leave the\nchanged default as-is, because otherwise you'll end up with invalid\ninlines just because you wanted to change the ordering.\n\n\nLimitations\n===========\n\n- ``OrderableAdmin`` can be used both for inlines and parents, but this\n also means that you cannot register a model directly with\n ``OrderableAdmin``.\n- Using django-admin-ordering with filtered or paginated lists may\n produce unexpected results. The recommendation right now is to set\n `list_per_page` to a bigger value and not reordering filtered\n changelists.\n- Note that django-admin-ordering assigns ordering values in increments\n of 10, emphasizing that the ordering value should not have any\n significance apart from giving relative ordering to elements.\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Orderable change lists and inlines done right^Wsimple",
"version": "0.19.1",
"project_urls": {
"Homepage": "https://github.com/matthiask/django-admin-ordering/"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "db9ca12f73e52b7bfff526910df5d8f1fff06b98c35f39e9784a86109dcb406e",
"md5": "5e1916a2f56139caf2e944c5962e2af6",
"sha256": "bfc0857677176599d1a811a1e4fa2d889c2650ad59de7b8f8679e0e2f41d0a85"
},
"downloads": -1,
"filename": "django_admin_ordering-0.19.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5e1916a2f56139caf2e944c5962e2af6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 21727,
"upload_time": "2024-11-22T11:49:02",
"upload_time_iso_8601": "2024-11-22T11:49:02.758378Z",
"url": "https://files.pythonhosted.org/packages/db/9c/a12f73e52b7bfff526910df5d8f1fff06b98c35f39e9784a86109dcb406e/django_admin_ordering-0.19.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "574cfa6e95035f6255f6e6a2748ed6a8d097cae58ba129ed8886604407b879d5",
"md5": "0c9a51f0caa8b85547520bd6af990fb1",
"sha256": "60f7d36ee69bf227bc9544b9b66ca226a6418bc2686be3e8375f3461710878e1"
},
"downloads": -1,
"filename": "django_admin_ordering-0.19.1.tar.gz",
"has_sig": false,
"md5_digest": "0c9a51f0caa8b85547520bd6af990fb1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 17954,
"upload_time": "2024-11-22T11:49:01",
"upload_time_iso_8601": "2024-11-22T11:49:01.091112Z",
"url": "https://files.pythonhosted.org/packages/57/4c/fa6e95035f6255f6e6a2748ed6a8d097cae58ba129ed8886604407b879d5/django_admin_ordering-0.19.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 11:49:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "matthiask",
"github_project": "django-admin-ordering",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "django-admin-ordering"
}