Models.py # Create your models here. from django.db import models class Menu(models.Model): name = models.CharField(max_length = 100) def __unicode__(self): return self.name class Item(models.Model): menu = models.ForeignKey(Menu) name = models.CharField(max_length = 100) url = models.CharField(max_length = 100) order = models.IntegerField(blank = True, null = True) def __unicode__(self): return self.name class Meta: ordering = ('order',) ---------------------------------------*********-------------------- View.py from django.shortcuts import render_to_response, get_list_or_404 from dragdrop.ordering.models import * def dragdropView(request): items = Item.objects.all() return render_to_response("login.html",{'items':items}); def reorder(request): orderlist = request.POST.get('order','').split('li2_') i = 1 for each in orderlist: if(len(each) > 1): if(each[each.rfind(',')+1:len(each)] != ''): item = Item.objects.get(name = each[each.rfind(',')+1:len(each)]) item.order = i item.save() i = i+1 dragdropView(request); ----------------------------------------- HTML Template --Name is login.html
------------------------------------------------------- Fixures [ { "model": "ordering.Menu", "pk": 1, "fields": { "name": "Project Management" } }, { "model": "ordering.Menu", "pk": 2, "fields": { "name": "E-Mail" } }, { "model": "ordering.Item", "pk": 1, "fields": { "menu": "1", "name": "First", "url": "abc.com", "order":"1" } }, { "model": "ordering.Item", "pk": 2, "fields": { "menu": "1", "name": "Second", "url": "abc.com", "order":"2" } }, { "model": "ordering.Item", "pk": 3, "fields": { "menu": "1", "name": "Third", "url": "abc.com", "order":"3" } } ] ---------------------------------------------------------------- DownLoad this from YUI- Library: Copy these folders from build directory of YUI library. 1. animation 2. dragdrop 3. utilities 4. yahoo-dom-event ------------------------- This will work fine -----------------