我正在使用 Geodjango 为我的系统实现地理定位系统,但它不断引发值错误
I'm using Geodjango to implement a geolocation system for my system but it keeps raising a value error
'''来自 django.contrib.gis.db 导入模型
class 商店(models.Model):
name = models.CharField(max_length = 100)
coords= models.PointField()
store_id = models.IntegerField()'''
Django 和 Geodjango 模型必须单独导入。
一种解决方案是正常导入 django 模型并对空间模型导入别名。
from django.db import models
from django.contrib.gis.db import models as sp_models
class Store(models.Model):
name = models.CharField(max_length=100)
coords = sp_models.PointField()
store_id = models.IntegerField()
'''来自 django.contrib.gis.db 导入模型
class 商店(models.Model):
name = models.CharField(max_length = 100)
coords= models.PointField()
store_id = models.IntegerField()'''
Django 和 Geodjango 模型必须单独导入。
一种解决方案是正常导入 django 模型并对空间模型导入别名。
from django.db import models
from django.contrib.gis.db import models as sp_models
class Store(models.Model):
name = models.CharField(max_length=100)
coords = sp_models.PointField()
store_id = models.IntegerField()