No. You can't pass arbitrary SQL functions to order_by.
>
> I can get the objects like this:
> MyObject.objects.filter(pk__in=my_ids_to_get)
> But I'm not able to build an order clause to use with it, and their
> order is not preserved.
>
> Do I have to fall back on raw sql to do this?
At the moment, certainly. At some point in the distant future, there's a
better than average chance that there will be a general way to pass
through literal SQL fragments in various places (including order_by()).
But it's pretty far down the feature list at the moment and will always
be fairly fragile in any case (because manipulations on query sets will
have to treat such fragments as opaque strings and so won't be able to
rename aliases inside them, etc).
Regards,
Malcolm