I am using mongodb-engine to access MongoDB from a Django project. Normal get, insert and update works quite well, but now would I like to use the geoNear functionality. I can just not figure out a way to call it from Django.
I have tried MyModel.objects.raw(...) and also MyModel.objects.raw_query(...), but the result is not really as expected.
The query will be something like this one (it works from the Mongo shell)
db.runCommand({ geoNear : "mymodel", near : [3, 0], spherical : true, maxDistance : 10 })
And the model uses MongoDBManager
class MyModel(model.Model):
objects = MongoDBManager()
...
has anyone successfully tried that?
Thx Simon
I guess the use of the MongoDB
db.runCommand(), which is needed for queries with geoNear, is just not possible with the current version of mongodb-enginge. I am using a raw_query with the normal near syntax now and convert the distance between the 2 lat/lon points myself to miles (and the other way around).