Excuse my ignorance, I am not even sure of the correct term for this. What I want to do is search by city and state or zip code in my django application and also include results within certain distances of the location (25, 50, 75 miles).
I am guessing you probably need to convert the city and state or zip code to lat and long and then search based on that. Is this correct or what is the best way to accomplish this in a django application? Does any one know of exiting apps that already do this, so I can look at the code?
Thanks for the help.
GeoDjango is a very powerful framework for storing and working with geographic data using the Django ORM. It provides an easy-to-use API to find the distances between two points on a map, areas of polygons, the points within a polygon, and so on.
Setup a Django App:Run the following command to create a Django app named searchapp. Run the following command to create the user for accessing the Django database. If you have created the user before then you don't need to run the command. Add the app name in the INSTALLED_APP part of the settings.py file.
These are full document-based search solutions. To use them with data from Django models, you'll need a layer which translates your data into a textual document, including back-references to the database ids. When a search using the engine returns a certain document, you can then look it up in the database.
You could use GeoDjango, which already includes these features. Otherwise you can do exactly as you said: geocode addresses to get latitude and longitude, then just do the math ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With