在模块django.contrib.gis.db中找不到GeoManager.Django 2.0中的模型 [英] Cannot find the GeoManager in module django.contrib.gis.db. models in Django 2.0

查看:77
本文介绍了在模块django.contrib.gis.db中找不到GeoManager.Django 2.0中的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究GeoDjango项目(第一次在Web应用程序中工作).尝试使用GeoManager,但弹出错误,提示模块'django.contrib.gis.db.models'没有属性'GeoManager'.之后,我检查了 Django 2.0的发行说明,发现在Django 2.0中删除了 GeoManager GeoQuerySet 类.

I am working on a GeoDjango project(first time working in a web app). Tring to use GeoManager but an error pops out saying module 'django.contrib.gis.db.models' has no attribute 'GeoManager'. After that, I checked the release notes of Django 2.0 and found out that the GeoManagerand GeoQuerySet classes are removed in Django 2.0.

有人知道现在在哪个模块中吗?还是有人可以建议其他更好的选择

Does anyone know which module is it in right now? Or can anyone suggest any better alternative

推荐答案

在Django 1.9中已弃用了它们,因为现在有替换它​​们的函数.

They were deprecated in Django 1.9 as there are now functions that are replacing them.

来自 1.9更改日志

所有GeoQuerySet方法均已弃用,并替换为等效数据库功能.遗留方法一经采用替换为您的代码后,您甚至应该可以删除特殊代码您启用了GIS的类中的GeoManager.

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.

这篇关于在模块django.contrib.gis.db中找不到GeoManager.Django 2.0中的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆