mongoengine的save方法已弃用? [英] mongoengine save method is deprecated?

查看:578
本文介绍了mongoengine的save方法已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么我的python为什么不推荐使用mongoengine save()方法吗?我没有在官方文档 https://mongoengine中看到有关此信息的任何信息.阅读thedocs.io/en/v0.9.0/apireference.html

I wonder why my python says that mongoengine save() method is deprecated? I don't see any info about this into official documentation https://mongoengine.readthedocs.io/en/v0.9.0/apireference.html

class MyModel(Document):
    user_id = StringField(required=True)
    date = DateTimeField(required=True, default=datetime.datetime.now)

my = MyModel()
my.user_id = 'user'
my.save()

现在我看到:

/Library/Python/2.7/site-packages/mongoengine/document.py:340: 弃用警告:不建议使用保存.使用insert_one或replace_one 代替

/Library/Python/2.7/site-packages/mongoengine/document.py:340: DeprecationWarning: save is deprecated. Use insert_one or replace_one instead

我已经安装了python 2.7,还安装了pymongo,mongoengine和bottle-mongo(也许有一些问题吗?)

I've python 2.7 and also installed pymongo, mongoengine and bottle-mongo (maybe some issues with that?)

推荐答案

MongoEngine包装了PyMongo,它在PyMongo 3.0中已弃用保存":

MongoEngine wraps PyMongo, which deprecated "save" in PyMongo 3.0:

http://api.mongodb.com/python/current /changelog.html#collection-changes

MongoEngine可能需要弃用其save方法,或取消弃用警告,或者可能需要其他一些修复程序来处理此PyMongo更改.我建议您搜索MongoEngine的错误跟踪器,如果尚未发现该问题,请报告该问题.

MongoEngine might need to deprecate its save method, or suppress the deprecation warning, or perhaps some other fix to handle this PyMongo change. I recommend you search MongoEngine's bug tracker and report this issue if it has not been already.

MongoEngine错误- https://github.com/MongoEngine/mongoengine/issues/1491

MongoEngine Bug - https://github.com/MongoEngine/mongoengine/issues/1491

这篇关于mongoengine的save方法已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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