views:

169

answers:

2

Hi there

I have a list of images in my admin area. I would like to add a upp/down button to every field. Clicking on the up field will move the image up in the order of images. So lets say its number 3 on the list and i click on it, it should now move to number 2. and also the same for moving down in the order of the list bly clicking on the down field, button or image.

Any ideas? Please not that I am still new to Django

A: 

You would probably have to create a model and associate it with the images in the admin. The admin is pretty extensible so if you're familiar with object oriented programming you should be able to overload some of the admin classes. With this in mind you should be able to...

  1. Create a model that has the image/image location and a weight value.
  2. create a custom admin view that utilizes this model.

Resources:

http://www.djangobook.com/en/1.0/chapter17

http://www.djangobook.com/en/beta/chapter18

Thomas Schultz
+1  A: 

This snippet will add "up" and "down" links next to every object in admin lists for a given model:

http://www.djangosnippets.org/snippets/998/

I use it in most of my project. I made a little reusable app out of it, by putting it in a separate dictionary (dont forget about the __init__.py file) - "# -------- the metaclass" portion inside models.py file, "# -------- the view" inside views.py and "# -------- the url config" inside urls.py.

Ludwik Trammer