mwebs
unread,May 16, 2008, 7:21:59 AM5/16/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello,
what I need is a modelField that provides sequence-functionality for a
model.
This field should have the following features:
- auto_increment when a new instance of the Model is created
- a method move_up() // Increments the sequence of the object
- a method move_down() // Decreases the sequence of the object
- a method sync_order() // Syncronizes all sequences; This sould be
called when a certain model-instance was deleted. The method finds the
"hole" and decreses all other items greater than the one that was
deleted.
My plan was to extend PositiveIntegerField and adding the desired
functionality.
But I could not figure out how to add auto_increment, without falling
back to raw sql.
...and how to add the 3 methods I mentioned above
Here a short example how a Model containing the SequenceField should
be used:
n = News.objects.get(pk = id)
n.moveUp() || n.moveDown()
I am relativley new to Django, and need some help of how to implement
this custom model field.
Thanks, Toni