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


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.8.0.tar.gz (17.4 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.8.0-py2.py3-none-any.whl (18.8 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for django-admin-ordering-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3a4a8d01b505b7e116c4788d08071be5291ae7020d1f2f5b10516b603773682f
MD5 7e1dfd7a81d0e60af218c212aebe20d7
BLAKE2b-256 cec51310750763f5af52a427fa079cc5c554c39f6061a7737ac0c35094bfdad6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_admin_ordering-0.8.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7c9fabc229279782176a5bbcb12e49d2723ad6792510463015d28d695342cf0b
MD5 3e03c6f04789592b3dca720916c46a36
BLAKE2b-256 1da3429cf7269909e0983df19efe92a7bd24fee008108b20754129d8239f5498

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