it was simple:
locations = Location.objects.filter(category=category.id,
status=2).extra(
select={'image': 'SELECT locations_images.image FROM
locations_images WHERE locations_images.location_id =
locations_location.id ORDER BY locations_images.order ASC LIMIT 1'
},
).only('name', 'slug')
On Aug 25, 7:29 pm, Federico Capoano <[email protected]> wrote:
> Hi to all django users,
>
> i just completed a project in which I used the extra() database API
> function in order to save the number of query used. Unfortunately the
> production server doesn't use Postgres but MySQL.
>
> I don't know why but I'm not making it to convert the query so it's
> compatible with MySQL, is there any good mate that can help me on
> this?
>
> This is the code:
>
> locations = Location.objects.filter(category=category.id,
> status=2).extra(
> select={
> 'image': 'SELECT "locations_images"."image" FROM
> "locations_images" '
> 'WHERE ('
> '"locations_images"."location_id" =
> "locations_location"."id"::integer '
> ')'
> ' ORDER BY "locations_images"."order" ASC LIMIT 1'
> },
> ).only('name', 'slug')
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.