Snippet List
Adds drag-and-drop ordering of rows in the admin list view for [Grappelli](http://code.google.com/p/django-grappelli/). This is based on [Snippet #2057](http://djangosnippets.org/snippets/2057/) and fixes some bugs as well as switching to jQuery/jQuery UI provided by Grappelli. No additional files need to be installed.
The model needs to have a field holding the position and that field has to be made list_editable in the ModelAdmin. The changes of the ordering are applied after clicking 'Save'.
- admin
- sort
- jquery
- order
- sortable
- grappelli
Adds drag-and-drop ordering of rows in the admin list view.
The only requirements is that the model has a field holding the position and that the field is made list_editable in the ModelAdmin. The changes of the ordering are applied after clicking 'Save'.
The included javascript uses [jQuery UI's sortable](http://jqueryui.com/demos/sortable/) plugin
Inspired by snippets [#1053](http://djangosnippets.org/snippets/1053) and [#998](http://djangosnippets.org/snippets/998/). Another similar snippet using AJAX is [#2047](http://djangosnippets.org/snippets/2047/).
- admin
- sort
- jquery
- order
- sortable
If you have a model that has an "ordering" column, and you want to be able to re-position records (eg, order items by priority), this base class should make it fairly easy. To use it, you extend your model using this abstract class, then hook up the pre_save event to the pre_save event of the base class, and you're good to go. Whenever you save an item, it ensures that it has a valid "order" number. The meat of this class is the "move()" method. Just call instance.move(number) where instance is your model instance, and this class will do all the logic necessary to shift around the order numbers for you.
- sort
- order
- sortable
- orderable
- sorted
- ordered
Use this abstract model if you want to add "order" to a given model. Once you do, you will get automatic "up" and "down" links for each model row.
One problem is that if the user sorts by another row, the up and down links are still there, but now don't make a lot of sense.
6 snippets posted so far.