Including GeoDjango Point in the Model

This is my first time working with GeoDjango, and it’s hard for me to add PointFieldto my model. Here is my model code:

from django.db import models
from django.contrib.gis.geos import Point
from django.contrib.gis.db import models

class Crime(models.Model):
    Category = models.CharField(max_length=50)
    Description = models.CharField(max_length=150)
    District =models.CharField(max_length=50)
    Incident = models.IntegerField(default=0)
    Date = models.DateTimeField(max_length=150,default="")
    Location = models.PointField()

When I try to create a migration, I get an error message:

ValueError: You cannot use an object of type float for a geometry search parameter.

When I try to create a crime object in the Python shell and save it, I get an error message:

django.core.exceptions.ValidationError

I have been eliminating this for a long time. I put the debugger in the actual gis library code and found that before it was thrown ValueError, it tried to treat the number 35.0as a geometry object.

, - Django , , - ?

+4
1

, lat + long, , gis . gis-, - .

, : http://south.aeracode.org/ticket/599

Location = models.PointField(default='POINT(0.0 0.0)')
+7

All Articles