Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django模型创建地理而非几何体字段_Django_Postgresql_Postgis_Sqlgeography_Sqlgeometry - Fatal编程技术网

Django模型创建地理而非几何体字段

Django模型创建地理而非几何体字段,django,postgresql,postgis,sqlgeography,sqlgeometry,Django,Postgresql,Postgis,Sqlgeography,Sqlgeometry,我有一个Django模型,在该模型中我声明maplocation=models.PointField()如果我使用python manage.py sql,它将映射为“maplocation”几何体(POINT,4326)而不是NULL 我需要做些什么才能使翻译正确?我真的不知道,但有一些提示: 您需要安装PostGIS 1.5+ 定义如下字段:maplocation=models.PointField(geography=True) 将模型管理器设置为django.contrib.gis.db

我有一个Django模型,在该模型中我声明
maplocation=models.PointField()
如果我使用python manage.py sql,它将映射为
“maplocation”几何体(POINT,4326)而不是NULL


我需要做些什么才能使翻译正确?

我真的不知道,但有一些提示:

  • 您需要安装PostGIS 1.5+

  • 定义如下字段:
    maplocation=models.PointField(geography=True)

  • 将模型管理器设置为
    django.contrib.gis.db.models.GeoManager
    (我认为使用地理信息时不需要这样做,但您稍后需要它来进行查询)