Reference for Django GeoModel

Showing 1-4 of 4 messages
Reference for Django GeoModel Elio Scordo 8/5/11 2:19 AM
Hi list,

I would like to migrate my geo-search (which now works with zipcodes) to Django geomodel project (

Could you point me to a little how-to? Would you recommend it?

I would like to integrate it with my Person Model.


Re: Reference for Django GeoModel Kyle Finley 8/5/11 3:20 PM
Hi Elio,

At it's current state I would not recommend using django-geomodel.

I started this port some time ago, but found without async support for Django that dense datasets were cumbersome and slow. If you have no other option and depending upon your data, it might work for you though.

Ideally the full text search ( will become available soon and render this obsolete.

To use django-geomodel you would do something like this:

# Mixin the GeoModel and AddressModel
class UserLocation(GeoModel, AddressModel):
    user = models.ForeignKey(User, related_name='locations')

class Zipcode(GeoModel, AddressModel):
    zip_class = models.CharField(_('zip class'), blank=True, max_length=100)
    county = models.CharField(_('county'), null=True, blank=True, max_length=150)    

from geomodel.geotypes import Point, Zipcode

def people_list(request, template_name='people/people_list.html'):
    results = UserLocation.objects.all()
    zipcode = request.GET.get('zipcode', '90210')
    if zipcode:
        zipcode = Zipcode.objects.get(zipcode=zipcode)
        center_point = Point(zipcode.latitude, zipcode.longitude)
        # Query by distance
        query_results = results.near(center_point, max_results=25,
                                 max_distance=75000, resolution=4)
        # Or Query by bounding box
        # query_results = results.within(north, east, south, west)
    return render(request, template_name, {
        'search_form': SearchForm(request.GET),
        'people': query_results,

I haven't tested this, so typos are likely. If you decide to use this and you have any issues let me know and I'll see what I can do. I added a note to the repo stating the projects incomplete state

- Kyle Finley
Re: Reference for Django GeoModel Jon Clement 12/8/11 11:40 AM

I've been layering features into my app and it's now time for geo based lookup of events.  I'm using django-nonrel and your port of the geomodel seems to fit my needs.

You mentioned that the feature will be replaced by Google's full text search.  I'm stuck.

How should I prepare my data for the full-text search?  Would creating a hash string out of lat/long work best (ie/ allow for 'starts_with" query)?

I'll likely do the hash AND implement your solution in the meantime.


Re: Reference for Django GeoModel Kyle Finley 12/8/11 12:29 PM
Hi Jon,

It's been some time since I've watched the video on full text search. I believe it creates its own entities in the datastore, but I'm not positive.

As for preparing your data - As long as you retain the lat/lon you should be alright. You can always loop through your models at a later date.

If you haven't already I would recommend that you signup for the full text search trusted testers.

Also, you might post these questions to the appengine python group. If you were willing to work on implementing full text search with django-nonrel that might increase the likelihood of being accepted as trusted tester.

Sorry I can't provide you with better information,

Kyle Finley