Adds simple object instance ordering to the Django administration change list.
Installing django-orderable is simple, just complete the following steps:
- Clone the django-orderable repository from GitHub.
- Run
python setup.py installto install the module package. - Add
orderableto theINSTALLED_APPStuple for your Django project. - Make sure the
orderable.jsfile is served by your favorite web server. - For any models that you would like to be ordered through the change list, have these models extend
orderable.models.OrderableModel, and have their admin classes implement or extendorderable.admin.OrderableAdmin. - Make sure that in your ModelAdmin, the
list_per_pageattribute is set to a value that is greater than the possible number of objects (this attribute defaults to 100). If you're looking to order an inordinate number of model instances, you might want to look elsewhere for your ordering solution.
You can also create orderable inlines in your administration site by creating inlines that extend orderable.admin.OrderableStackedInline or orderable.admin.OrderableTabularInline.
Please note that this isn't a fool-proof solution to ordering objects in every scenario. However, this app is useful for small applications where the change list will not be paginated beyond the first page of model instances. There are a lot of cases where this application isn't the appropriate solution (at least currently), such as objects that are ordered with respect to a related object, situations where the list_filter will be implemented, etc.
The test application can be run with the manage-tests.sh script in the root directory of the repository. (Please note that the script does need to be executed with the root as the repository as $PWD, or else the $PYTHONPATH environment variable will not be set correctly.) It takes any valid arguments to the environment's django-admin.py command. When creating the database, it creates a default superuser, with the username admin and password password, as well as some test data to play with in the administration panel.