3.0中不推荐使用的功能
django.utils.encoding.force_text()和smart_text()的别名被弃用。如果您的代码支持Python 2,smart_str()并且 force_str()在此处有所不同,请忽略此弃用。
杂项
-
django.utils.http.urlquote(),urlquote_plus(),urlunquote(),并urlunquote_plus()在赞成不赞成使用的功能,他们正在别名:urllib.parse.quote(),quote_plus(),unquote(),和unquote_plus()。 -
django.utils.translation.ugettext(),ugettext_lazy(),ugettext_noop(),ungettext(),并ungettext_lazy()在赞成不赞成使用的功能,他们正在别名:django.utils.translation.gettext(),gettext_lazy(),gettext_noop(),ngettext(),和ngettext_lazy()。 -
为了限制会话的创建并因此支持某些缓存策略,
django.views.i18n.set_language()将停止在Django 4.0中的会话中设置用户的语言。从Django 2.1开始,该语言始终存储在LANGUAGE_COOKIE_NAMEcookie中。 -
django.utils.text.unescape_entities()不推荐使用html.unescape()。请注意,与不同unescape_entities(),它会html.unescape()立即评估惰性字符串。 -
为了避免在有效范围方面造成混淆,将专用内部实用程序
is_safe_url()重命名为url_has_allowed_host_and_scheme()。URL具有允许的主机和方案,通常并不表示其“安全”。例如,它可能仍然引用不正确。确保还在iri_to_uri()不可信URL的路径组件上使用 。
3.0中删除的功能
这些功能已到弃用周期的尽头,并已在Django 3.0中删除。
有关这些更改的详细信息,请参阅2.0中不推荐使用的功能,包括如何删除对这些功能的使用。
-
该
django.db.backends.postgresql_psycopg2模块已卸下。 -
django.shortcuts.render_to_response()已移除。 -
该
DEFAULT_CONTENT_TYPE设置将被删除。 -
HttpRequest.xreadlines()已移除。 -
为支持
context的论据Field.from_db_value()和Expression.convert_value()被删除。 -
所述
field_name的关键字参数QuerySet.earliest()和latest()被去除。
有关这些更改的详细信息,请参阅2.1中不推荐使用的功能,包括如何删除对这些功能的使用。
-
该
ForceRHRGIS功能被删除。 -
django.utils.http.cookie_date()已移除。 -
在
staticfiles和admin_static模板标签库被删除。 -
django.contrib.staticfiles.templatetags.staticfiles.static()已移除。