On Mon, Jul 11, 2011 at 10:02 AM, sanket <[email protected]> wrote:

> I think I would go ahead with executing the raw SQL in this case.
> The solution by @Venatraman looks interesting too. I would give it a
> try.
>

Raw-sql and the snippet provided by me would end up generating the same sql.

One advantage of my snippet is, if your db does not support sin/cos
functions(like sqlite3),
then you can go ahead defining funcs which computes the same. Something
like..
                        from django.db import connection, transaction
                        cursor = connection.cursor()
                        import math
                        connection.connection.create_function('acos', 1,
math.acos)
                        connection.connection.create_function('cos', 1,
math.cos)
                        connection.connection.create_function('sin', 1,
math.sin)

-V

-- 
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.

Reply via email to