Skip to main content

Orderable change lists and inlines done right^Wsimple

Project description

==============================================================================
django-admin-ordering -- Orderable change lists and inlines done right^Wsimple
==============================================================================

.. image:: https://travis-ci.org/matthiask/django-admin-ordering.svg?branch=master
:target: https://travis-ci.org/matthiask/django-admin-ordering

Please refer to the Travis 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.


Orderable change lists
~~~~~~~~~~~~~~~~~~~~~~

::

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: '-order'
ordering_field = 'order'

# You may optionally hide the ordering field in the changelist:
# ordering_field_hide_input = False

# The ordering field must be included both in list_display and
# list_editable:
list_display = ('name', 'order', )
list_editable = ('order', )


Orderable inlines
~~~~~~~~~~~~~~~~

::

from admin_ordering.admin import OrderableAdmin

class MyModelTabularInline(OrderableAdmin, admin.TabularInline):
model = MyModel

# You have to set the name of the parent foreign key yourself:
fk_name = 'parent'

# Same as above; '-order' is also allowed here:
ordering_field = 'order'
# ordering_field_hide_input = 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
===========

- Starting with Django 1.9 newly created inlines are automatically assigned
a good ordering value. Earlier versions do not support the required
``formset:added`` signal.
- ``OrderableAdmin`` can be used both for inlines and parents, but this
also means that you cannot register a model directly with
``OrderableAdmin``.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-admin-ordering-0.9.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_ordering-0.9.0-py2.py3-none-any.whl (19.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-admin-ordering-0.9.0.tar.gz.

File metadata

  • Download URL: django-admin-ordering-0.9.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for django-admin-ordering-0.9.0.tar.gz
Algorithm Hash digest
SHA256 a406fe8bfb4a6e3d8e929cedb42af85c2d6545a27d8b8717c5eaaa1cb7e07848
MD5 5a14004f22d48e056e72caab2ff514ae
BLAKE2b-256 e92c3de989b4d68f6ddb242172643662334530fe18cc833382f347697a83238d

See more details on using hashes here.

File details

Details for the file django_admin_ordering-0.9.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_admin_ordering-0.9.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for django_admin_ordering-0.9.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cea13b9fe455c304f80d52a6e8ceb694d96fc7ff50fef5a6fb74bc079eee1c08
MD5 d3ea2b867964f522d37146b3e13a065f
BLAKE2b-256 85625523eb545a013e6635708993d41ac3a2972b857e1292bdc9cd654bbf596a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page