Hey All,

I am quite new to Django and recently started using django for
developing a location based service.
In order to find the places in near by area I want to make following
mysql query. but I am not sure how should I translate it using django
models and managers.

orig.lat = x
orig.lon = y

"SELECT  destination.*,
3956 * 2 * ASIN(SQRT(  POWER(SIN((orig.lat - dest.lat) * pi()/180 /
2), 2) +
COS(orig.lat * pi()/180) *  COS(dest.lat * pi()/180) *
POWER(SIN((orig.lon -dest.lon) * pi()/180 / 2), 2)  )) as
distance
FROM place as dest
WHERE  dest.longitude
BETWEEN lon1 and lon2
AND dest.latitude
BETWEEN lat1 and lat2
"

the model which talks to database is called Place in my case.

Thank you all for the help,
sanket

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to