python - 在模块 django.contrib.gis.db 中找不到 GeoManager。 Django 2.0 中的模型

标签 python django geodjango

我正在开发一个 GeoDjango 项目(第一次在网络应用程序中工作)。尝试使用 GeoManager,但弹出错误,提示模块“django.contrib.gis.db.models”没有属性“GeoManager”。之后我查了release notes of Django 2.0发现 Django 2.0 中删除了 GeoManagerGeoQuerySet 类。

有人知道它现在在哪个模块吗?或者谁能​​提出更好的替代方案

最佳答案

它们在 Django 1.9 中已被弃用,因为现在有函数正在取代它们。

来自1.9 changelog

All GeoQuerySet methods have been deprecated and replaced by equivalent database functions. As soon as the legacy methods have been replaced in your code, you should even be able to remove the special GeoManager from your GIS-enabled classes.

关于python - 在模块 django.contrib.gis.db 中找不到 GeoManager。 Django 2.0 中的模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48839817/

相关文章:

python - Django按距离排序

AWS EC2 上的 Django 和 GeoDjango,RDS 上的 Postgres Postgis

python - Django-tenant-schemas 和 GeoDjango 一起

python - 使用 geopy 将英里转换为纬度和经度

python - 如何让 WebDriverWait 查找特定号码

python - sorted(dict, dict.get) 如何处理重复值

django - modelForm 中的查询集

javascript - 使用django从html格式下载图像到本地主机

python - 如何在 python ArgumentParser.add_argument() 中包含正则表达式选项?

python - 如何在Django中的views.py中的一个类下显示模型和表单?