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 中的弃用警告?
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 沿轴计算直方图 2022-01-01
- 如何将一个类的函数分成多个文件? 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
