Python – How to assign to a Django PointField model attribute


Hi I have a Django Model as follows:

class Address(models.Model):
    geoCoords = models.PointField(null=True, blank=True,)

Now I create an instance of this model:

A = Address()

How can I set the coordinates of A's geoCoord field to (5.3, 6.2)? I can't find any example of where a point field is assigned to in this way. It's such a stupidly simple question. Actually, the coordinates I would like to assign to A.geoCord are from pygeocoder. It is a 2-item tuple of floats.

The documentation on Django PointFields is basically non-existant.

Best Solution

In newer versions of Django you can:

from django.contrib.gis.geos import Point
pnt = Point(1, 1)

Plenty of examples available in