Have you used OrderingField?

7 views
Skip to first unread message

Julien

unread,
Apr 15, 2008, 12:50:29 AM4/15/08
to Django users
Hi,

I've stumbled on OrderingField in django.db.models.fields.

That looks very interesting to me but I could not find any example of
use, either in Django itself or on the web.

Do you know what it is, and how to use it?

Thanks a lot!

Julien


PS: Here's its code:

class OrderingField(IntegerField):
empty_strings_allowed=False
def __init__(self, with_respect_to, **kwargs):
self.wrt = with_respect_to
kwargs['null'] = True
IntegerField.__init__(self, **kwargs )

def get_manipulator_fields(self, opts, manipulator, change,
name_prefix='', rel=False, follow=True):
return [oldforms.HiddenField(name_prefix + self.name)]

Karen Tracey

unread,
Apr 15, 2008, 9:23:20 AM4/15/08
to django...@googlegroups.com
On Tue, Apr 15, 2008 at 12:50 AM, Julien <jph...@gmail.com> wrote:

Hi,

I've stumbled on OrderingField in django.db.models.fields.

That looks very interesting to me but I could not find any example of
use, either in Django itself or on the web.

Do you know what it is, and how to use it?

No, but from looking around in the SVN history you can find that the code was added on the magic-removal branch in a changeset (1780) with the comment:

steps towards ordering in edit-inline and spreadsheetish editing in changelists using ManipulatorCollections

ManipulatorCollection never made it to trunk, it was removed from the magic-removal branch in changeset 2103 with the comment:

Restored manipulators to code from trunk, removing the unfinished stuff

So, whatever OrderingField was supposed to be used for, it doesn't seem to have ever been finished.  The code looks to be dead.

Why does it look interesting to you?  Perhaps there is an actually implemented mechanism to do whatever you thought OrderingField might do, if you explain what you thought it might be useful for.

Karen



 

Julien

unread,
Apr 16, 2008, 9:41:26 AM4/16/08
to Django users
Thanks Karen for the clarification! That code looked dead to me too...
is that worth filing a ticket?

It seemed interesting to me because I was looking for some kind of
mechanism that would make it easy to define "orderable" objects. For
example, elements of a list, or children of a tree branch, ordered by
an arbitrary integer value. I have implemented that mechanism once,
but I found it very tedious to maintain. To me it seems like a generic
behaviour so I was hoping Django would offer something out of the
box :)

Is there anything in Django that helps with that? If not, I have found
that code [1], which looks like a good start. What do you think?

Thanks!

Julien

[http://blog.vicox.net/2008/03/10/orderingfield-for-django/]



On Apr 15, 11:23 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:

Julien

unread,
Apr 16, 2008, 9:42:26 AM4/16/08
to Django users
Sorry, here's the proper link:

[1] http://blog.vicox.net/2008/03/10/orderingfield-for-django/

Karen Tracey

unread,
Apr 16, 2008, 1:36:32 PM4/16/08
to django...@googlegroups.com
On Wed, Apr 16, 2008 at 9:41 AM, Julien <jph...@gmail.com> wrote:
Thanks Karen for the clarification! That code looked dead to me too...
is that worth filing a ticket?

I'd say its worth removing dead code to avoid confusion, but that's just my opinion.  The core devs may feel it's not worth worrying about.  If you open a ticket worst case it gets closed wontfix, but even then someone who comes along later and has the same question might think to search the tracker and find that someone else came to the same conclusion.

It seemed interesting to me because I was looking for some kind of
mechanism that would make it easy to define "orderable" objects. For
example, elements of a list, or children of a tree branch, ordered by
an arbitrary integer value. I have implemented that mechanism once,
but I found it very tedious to maintain. To me it seems like a generic
behaviour so I was hoping Django would offer something out of the
box :)

Is there anything in Django that helps with that? If not, I have found
that code [1], which looks like a good start. What do you think?

I don't know of anything built-in that will help here, so I'd give what you found a try.  I've never had a need for this myself so I can't say I've given a lot of thought to the best way to approach it.

Karen
 

alex....@gmail.com

unread,
Apr 16, 2008, 1:44:45 PM4/16/08
to Django users
FWIW this seems like something that would go hand in hand with
portions of #13

On Apr 16, 12:36 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:

Malcolm Tredinnick

unread,
Apr 16, 2008, 9:24:05 PM4/16/08
to django...@googlegroups.com

On Wed, 2008-04-16 at 06:41 -0700, Julien wrote:
> Thanks Karen for the clarification! That code looked dead to me too...
> is that worth filing a ticket?

It's not harmful and it could well be useful to some people who are
using with order_with_respect_to, for example.

Regards,
Malcolm

--
The cost of feathers has risen; even down is up!
http://www.pointy-stick.com/blog/

Malcolm Tredinnick

unread,
Apr 17, 2008, 2:03:24 AM4/17/08
to django...@googlegroups.com

On Thu, 2008-04-17 at 11:24 +1000, Malcolm Tredinnick wrote:
>
> On Wed, 2008-04-16 at 06:41 -0700, Julien wrote:
> > Thanks Karen for the clarification! That code looked dead to me too...
> > is that worth filing a ticket?
>
> It's not harmful and it could well be useful to some people who are
> using with order_with_respect_to, for example.

Scrub that. For some reason my brain had switched over to thinking about
form fields, not model fields. On second glance, this doesn't seem to be
particularly useful as it stands. We could consider removing it.

Malcolm

--
If it walks out of your refrigerator, LET IT GO!!
http://www.pointy-stick.com/blog/

Reply all
Reply to author
Forward
0 new messages