DJANGO and AJAX

Writing generic code

Bulk gets

Date: Sat, 6 Jun 2009 08:48:25 -0700 (PDT)
From: Daniel Roseman roseman.daniel@googlemail.com
Subject: Re: Bulk get
To: Django users django-users@googlegroups.com

...

If you've got the order already in model_pk_list, you can use the order_by parameter to .extra() to get the results in that order straight from the database.

x = MyModel.objects.filter(pk__in=model_pk_list).extra(order_by=model_pk_list)

This works for MySQL at least, not sure about other backends.

...

Add ons