GeoDjango & MySQL: points can't be NULL, what other “empty” value should I use?

后端 未结 3 1532
不思量自难忘°
不思量自难忘° 2021-01-18 09:21

I have this Django model:

from django.contrib.gis.db import models

class Event(models.Model):
    address = models.TextField()
    point = models.PointField         


        
3条回答
  •  日久生厌
    2021-01-18 10:03

    A quick idea would be to have another boolean field that you mark as true/false when you have an actual point. It would make querying easy because you could add the boolean field to the where clause.

    class Event(models.Model):
        ...
        has_point = models.BooleanField(default=False)
        point = models.PointField('coordinates', ...)
    
    Event.objects.filter(has_point=True)...#whatever else you need when handling location
    

提交回复
热议问题