2014-08-21 00:47:13 +00:00
Quickstart
==========
To get started using `` django-admin-sortable `` simply install it using `` pip `` ::
2020-07-22 08:52:33 +00:00
.. code-block :: bash
2014-08-21 00:47:13 +00:00
$ pip install django-admin-sortable
Add `` adminsortable `` to your project's `` INSTALLED_APPS `` setting.
Ensure `` django.core.context_processors.static `` is in your `` TEMPLATE_CONTEXT_PROCESSORS `` setting.
2014-08-21 03:34:31 +00:00
Define your model, inheriting from `` adminsortable.Sortable `` ::
2020-07-22 08:52:33 +00:00
.. code-block :: python
2014-08-21 03:34:31 +00:00
# models.py
from adminsortable.models import Sortable
class MySortableClass(Sortable):
class Meta(Sortable.Meta):
pass
title = models.CharField(max_length=50)
def __unicode__(self):
return self.title
Wire up your sortable model to Django admin::
2020-07-22 08:52:33 +00:00
.. code-block :: python
2014-08-21 03:34:31 +00:00
# admin.py
from adminsortable.admin import SortableAdmin
from .models import MySortableClass
class MySortableAdminClass(SortableAdmin):
"""Any admin options you need go here"""
admin.site.register(MySortableClass, MySortableAdminClass)
Your model's ChangeList view should now have an extra tool link when there are 2 or more objects present that will take you to a view where you can drag-and-drop the objects into your desired order.