在我的Django应用程序中,当我导入一个第三方库时,控制台会显示如下警告信息:
上述代码会导致另一个错误信息,提示RemovedInDjango110Warning不存在。我还尝试了以下代码:
但我仍然收到了完全相同的错误信息。所以,看起来所有之前解决此问题的答案都已经过时了。我们需要一些新的修复方法。谢谢!
我也尝试了这个:
然而,如果我在Python shell中进行导入,则一切正常。我想在Django中实现相同的行为。基于其他操作系统主题的答案,我已经尝试了以下方法:the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import warnings
from django.utils.deprecation import RemovedInDjango110Warning
warnings.filterwarnings(action="ignore", category=RemovedInDjango110Warning)
上述代码会导致另一个错误信息,提示RemovedInDjango110Warning不存在。我还尝试了以下代码:
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()
from third_party_lib import some_module
但我仍然收到了完全相同的错误信息。所以,看起来所有之前解决此问题的答案都已经过时了。我们需要一些新的修复方法。谢谢!
我也尝试了这个:
import warnings
with warnings.catch_warnings():
warnings.filterwarnings("ignore",category=DeprecationWarning)
from third_party_lib import some_module
但是它没有任何效果。
DeprecationWarning
或PendingDeprecationWarning
警告? - Alasdair