Hey all,

I've been having an issue using the filter on a GeoQuerySet with
Django 1.1.

I have a "Locations" table that looks more or less like this:

class Location(models.Model):
    pnt = models.PointField()
    name = models.CharField(max_length=255)

To query, I look for an object like this:

>>> Location.objects.filter(pnt="POINT(-122.421961 37.767019)")
[<Location: Fourbarrel Coffee>]

Then, I go into the admin, view this object, don't make any changes,
but then click "Save".

I run this command again and get nothing:

>>> Location.objects.filter(pnt="POINT(-122.421961 37.767019)")
[]

Interesting.... Shouldn't the admin not change this object at all? It
turns out that simply by clicking save in the admin, the object
changed to have the following point:

>>> l=Location.objects.filter(name='Fourbarrel Coffee')
>>> print l.pnt
POINT (-122.4219609999999960 37.7670189999999835)
>>> print l.pnt.x
-122.421961
>>> print l.pnt.y
37.767019

Hmm.. Maybe searching for the location using the Point object will be
more accurate?

>>> from django.contrib.gis.geos import *
>>> pnt  = Point(-122.421961, 37.767019)
>>> Location.objects.filter(pnt=pnt)
[]

Nope. Well let's go with the wkt text we got back:

>>> wkt = "POINT (-122.4219609999999960 37.7670189999999835)"
>>> Location.objects.filter(pnt=wkt)
[<Location: Fourbarrel Coffee>]


Clearly something is wrong here if viewing an object in admin, not
changing anything, and then clicking save *changes* the object. I'm
assuming that this is a bug in the OSMAdmin that places the point on
the map for the view, and then on save, uses the point on the map to
save... but for some reason saves it ever so slightly off.  I'm using
django 1.1 (official release) and Postgres 8.4 for my database. This
is the admins file I'm using for the Location object:

from django.contrib.gis import admin
from models import Location

class LocationAdmin(admin.OSMGeoAdmin):
    search_fields = ['name']

admin.site.register(Location, LocationAdmin)


I'm assuming this is a bug -- but I'm sending it to you all to confirm
that I'm not just missing something obvious.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to