Hank
Hank

Reputation: 3497

Django - storing sortable search results

I have a search function looking for the nearest landmarks based on the user's entered location and radius from location. I want the search results to be able to sort by distance from user's location or by some other metrics I determine. The metrics will come from various tables in my database, but the distance will not because it depends on what the user enters.

I was wondering what is the best way to store all these different sortable values temporarily?

Here's an example of the results

Landmark  |   Distance  |   Metric1   |   Metric2
-------------------------------------------------
Mark1     |     24      |      2      |    3
Mark2     |     13      |      4      |    5 
Mark3     |     4       |      6      |    8

Landmark, Metric1, and Metric2 will all come from a database. Distance will be generated at the search results page. Distance, Metric1, and Metric2 will be sortable.

Upvotes: 0

Views: 80

Answers (1)

jkeesh
jkeesh

Reputation: 3339

I'm not sure what kind of storing you need, but if you only want it temporarily that seems like you may want to use a cache. We use Django for our project and use Redis as a cache backend. There are several projects that make it easy to integrate, we use:

https://pypi.python.org/pypi/django-cacheops/0.8.1

Upvotes: 1

Related Questions