How to suppress the deprecation warnings in Django?(如何抑制 Django 中的弃用警告?)
问题描述
每次我使用 django-admin 命令时——甚至在 TAB 完成时——它都会抛出一个 RemovedInDjango19Warning (如果我使用 test 命令).如何抑制这些警告?
Every time I'm using the django-admin command — even on TAB–completion — it throws a RemovedInDjango19Warning (and a lot more if I use the test command). How can I suppress those warnings?
我正在使用 Django 1.8 和 Python 3.4(在虚拟环境中).据我所知,所有这些警告都来自库而不是我的代码.
I'm using Django 1.8 with Python 3.4 (in a virtual environment). As far as I can tell, all those warnings come from libraries not from my code.
这里有一些例子:
…/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.contrib.contenttypes.generic 已弃用,将在 Django 1.9 中删除.它的内容已移至 django.contrib.contenttypes 的字段、表单和管理子模块.返回 f(*args, **kwds)
…/lib/python3.4/site-packages/django/contrib/admin/util.py:7: RemovedInDjango19Warning: django.contrib.admin.util 模块已重命名.请改用 django.contrib.admin.utils."改用 django.contrib.admin.utils.", RemovedInDjango19Warning)
…/lib/python3.4/site-packages/django/templatetags/future.py:25: RemovedInDjango19Warning: 从``future`` 库加载``url`` 标签是已弃用并将在 Django 1.9 中删除.请改用默认的 ``url`` 标签.RemovedInDjango19Warning)
自 Django 1.11 版(发行说明) 默认情况下,弃用警告不再响亮.所以我想这不再是问题了,因为 1.11 是支持 Python 2 的最后一个版本,并且还提供长期支持.
Since Django version 1.11 (release notes) deprecating warnings are no longer loud by default. So I guess this won't be an issue anymore, since 1.11 is the last version to support Python 2 and also features long-term support.
推荐答案
这个留给新人吧:
至于 django 1.11 弃用警告默认不再响亮.例如,要激活它们,请运行 python -Wd manage.py runserver.
As for django 1.11 deprecating warnings are no longer loud by default. To activate them run python -Wd manage.py runserver for example.
来源
这篇关于如何抑制 Django 中的弃用警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何抑制 Django 中的弃用警告?
基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
