Geodjango: PointField and GEOSGeometry
The accepted answer is incorrect. Points take the form of "POINT(longitude latitude)". You've reversed them.
You can surely do that, but with a slight modification
point = GEOSGeometry('POINT(%s %s)' % (lon, lat))
OR
point = GEOSGeometry('POINT(%d %d)' % (lon, lat))
When you do
`'POINT(lat lon)'`
you are not replacing the local variables lat
and lon
with their appropriate local variable values, and they are being evaluated literally. So, you would need to use substitution.
EDIT: Changed order of (lat, lon)
to (lon, lat)
to match the order GEOSGeometry
is expecting. Although not explicitly stated in the documentation, it is evident from their examples.