On Friday 03 March 2006 01:01, Malcolm Tredinnick wrote:
> Unfortunately, Meta.ordering seems to want a real field, not a method
> (which Admin.list_display can take) or a property.
>
> So am I missing something, or is this even a common need for other
> people?
Meta.ordering does ordering in the database using an SQL 'ORDER BY'
clause, so you can't use a function defined in your model to do that
ordering.
A solution (or part of one) is available in magic-removal. You can
create your own custom manager, and it has a method get_query_set that
you can override. You could then create a subclass of QuerySet that
has certain methods overridden to do ordering after the data is
returned. (I think the one you'd need to override is
QuerySet._get_data).
The first 'Manager' to be defined is used as the default one, so your
custom manager would work in the Admin and elsewhere.
There may still be issues in getting this to play well with other
ordering, I'm not sure, but they should be fixable.
Luke
--
"The first ten million years were the worst. And the second ten
million, they were the worst too. The third ten million, I didn't enjoy
at all. After that I went into a bit of a decline." (Marvin the
paranoid android)
Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---