use GeoManager on models to allow spatial queries

This commit is contained in:
Sanj 2012-05-23 15:33:44 +05:30
parent 53037c064f
commit ccface0748
2 changed files with 22 additions and 9 deletions

View File

@ -53,7 +53,7 @@ RUNTIMES = (
(20, 24)
)
class TrigramSearchManager(models.Manager):
class TrigramSearchManager(models.GeoManager):
def __init__(self, trigram_columns=[]):
super(TrigramSearchManager, self).__init__()
self.trigram_columns = trigram_columns
@ -229,6 +229,7 @@ class Route(models.Model):
distance = models.DecimalField(max_digits=3, decimal_places=1)
stages = models.IntegerField()
class Meta:
ordering = ['code']

View File

@ -20,14 +20,26 @@ a:hover {
{% endblock %}
{% block body %}
<ul id="stopList">
{% for s in stops %}
<li>
<a href="{{ s.get_absolute_url }}" class="{% if s.point %} has_point {% else %} no_point {% endif %}">{{ s.name }}</a>
</li>
<div id="stopListWrapper" class="listColumn">
<ul id="stopList">
{% for stop in stops %}
<li>
<a href="{{ stop.get_absolute_url }}">{{ s.name }}</a>
</li>
{% endfor %}
</ul>
</div>
<div id="routeListWrapper" class="listColumn">
<input class="listFilterInput" placeholder="Filter..." />
<ul id="routeList">
{% for route in routes %}
<li>
<a href="{{ route.get_absolute_url }}">{{ route.alias }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</ul>
</div>
<div id="map"></div>
{% endblock %}