I am working with GeoDjango for the first time and am having trouble adding a PointField
to 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 the error:
ValueError: Cannot use object with type float for a geometry lookup parameter.
When I try to create a crime object in the Python shell and save it I get the error:
django.core.exceptions.ValidationError
I've been troubleshooting this for quite a while now. I put a debugger in the actual gis library code and found that right before the ValueError
was thrown, it was trying to process the number 35.0
as a geometry object.
I'm wondering if this error either has something to do with needing to set defaults in Django or if something is possibly wrong with my database connection?