[Fixed]-How can distant calulate query convert to django base?

1👍

Since you referred django models so I would suggest you to dive into geo django specially designed to handle geo related stuff. Here is reference for calculating distance between 2 points click here.

If you dont wanna make such changes in configurations and use existing setup, then I would suggest to write sql for the same rather than python as you might need more filtering or ordering which will have a huge impact on performance.

0👍

I don’t know enough about databases to give you a satisfying answer, but it seems like you have a database engine that is specifically engineered for calculations.
I don’t think Django’s ORM is built to handle this specific database language.

You could take a look at the Django documentation about aggregating functions and if that doesn’t work, you can always fall back to performing raw sql in Django.

Personally, I would execute the calculations in Python though. In that case you just need to get the variables you want and use Python’s math library to execute the calculation.

I hope this gives you some pointers in the right direction.

Leave a comment