README.rst

Django Generic Positions

This is a generic app for using a drag & drop position field, wherever you want
to.

You often have items that should have a position field so that the user
can manipulate their ordering by entering intergers into that field. This app
allows you to easily add drag and drop functionality to that model's Django
admin or even to your frontend.

You don't need to manipulate your models, which means that you can even make
third party models that don't have a position field at all position aware.

IMPORTANT. If you are using multiple models, which have generic relations to
the positioning model, this is what you should NOT do: For some reason there
will be duplicates of your model appearing in the templates. Please don't use
ordering = ['generic_position__position'].

Usage in templates

There are several template tags and filters you can use. Let's start with a
simple view, which orders the object list by position:

Inside the form you need a wrapper element that wraps all your position aware
items. A <ul id="positionContainer"> tag is usually recommended.

Make sure that your wrapper element has the ID positionContainer.

Next to each of your position items you need to render a hidden field with
its current position, that can be posted to the form. Use the template tag
{% position_input obj %} to automatically add the right input field.

Usage with Django Admin

If you want to use the drag & drop positioning in the Django admin use: