[Answered ]-Complex query in django

1👍

Take a look at this SO post. It covers a geo lookup like you want.

👤Tom

1👍

The Django ORM doesn’t suppport HAVING; drop to DB-API for this.

0👍

User raw() method and that SQL query to get Cars objects.

0👍

You’ll have a hard time returning the distance value inside a QerySet object (see my question on the same thing), at least until Django 1.2. The easiest thing is to just move your query into a model manager, but return a Python list instead of a queryset. You might also look at Python’s geo library for handling these kinds of queries.

👤Tom

Leave a comment