django-ordered-model icon indicating copy to clipboard operation
django-ordered-model copied to clipboard

Support for drag'n'drop

Open blueyed opened this issue 11 years ago • 6 comments
trafficstars

Is it planned to add optional support for dragging and dropping rows, e.g. in an inline admin form?

It would probably be possible to use Grappelli's inline sortables with an OrderedModel.

blueyed avatar Jul 04 '14 14:07 blueyed

For what it's worth, I will be making a pass at this and a couple other alternative widgets for ordering models. (I know this is a really... really old issue).

  1. the user re-orders the list in place.
  2. The user drags from an unordered group of objects and creates an ordered list.

derek-adair avatar Aug 13 '17 14:08 derek-adair

@derek-adair quite old, but still wanted 👍

sysradium avatar Aug 27 '17 14:08 sysradium

I made a quick hack to allow drag'n'drop in the admin by extending the OrderedModelAdmin, see this gist:

https://gist.github.com/devsnd/38b9d4ff573a0611a87f10ab3042db45

Just use DragndropOrderedModelAdmin instead of OrderedModelAdmin when creating your admin class and add make_draggable as list_display item, which renders the necessary HTML/JS into the admin.

It requires the browser to support HTML5 Drag'n'Drop. It's quick and dirty, but it also just works ™

To change item order, just drag the row over another row. The dragged row will then be placed above the row it has been dragged on.

devsnd avatar Nov 03 '17 11:11 devsnd

The above hack works like a charm! Added some comments on the gist for anyone looking to implement this.

bpartridge avatar Oct 09 '19 04:10 bpartridge

anyone have it working with a current version?

lsmith77 avatar Oct 10 '23 17:10 lsmith77