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``.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-admin-ordering-0.8.1.tar.gz
.
File metadata
- Download URL: django-admin-ordering-0.8.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b73959c2c2f25d1a8b4fb57dea7870295c6cfd318dd0de9e3ed96943b9e6df |
|
MD5 | 168dd4ff651e3a6f6031806b73aa9e9c |
|
BLAKE2b-256 | 5fbd1ab7730de151e2a8d387cff5bc1f7fdca7789f6522a3ece5efdb776481bb |
File details
Details for the file django_admin_ordering-0.8.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin_ordering-0.8.1-py2.py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47534423a85ac800a01337d9690e6dd7cbf04cf23cbc954da695b5d9477701a3 |
|
MD5 | ccdc2eb5d311c53f1afe3aaeaeddc53e |
|
BLAKE2b-256 | 7b9ea3444acde71c317be129d60641ef2faadfe7ace93e951dd45e7af0fb78e0 |