python - Django 2.0 中 "django.core.xheaders"的替代 Django 包

标签 python django django-views django-migrations

我正在将旧的 Django 项目迁移到 Django 2.0。在其中一个 View 文件中,我遇到了一个 import 语句:

from django.core.xheaders import populate_xheaders

我正在尝试找出这个包的替代方案 - 既不在 google 中也不在 stackoverflow 中。

谁能帮我找到替代包?

最佳答案

django.core.xheaders 在 Django 1.6 中被移除。以下消息在删除后添加到文档中:

The django.contrib.flatpages app used to set custom HTTP headers for debugging purposes. This functionality was not documented and made caching ineffective so it has been removed, along with its generic implementation, previously available in django.core.xheaders.

我怀疑您可以在您正在移植的应用程序中删除对此函数的调用。

如果您确实需要这些 header ,您可以从 the commit where it was removed 复制功能.

有关最初创建此函数的原因的信息,请参阅 the ticket that tracked its addition .

关于python - Django 2.0 中 "django.core.xheaders"的替代 Django 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49388994/

相关文章:

python - 如何在 PySpark 中构建稀疏矩阵?

django - 我可以从另一个 View 中调用一个 View 吗?

python - ImportError at/login 没有名为登录的模块

django - 找不到页面 (404)

python - python2.6应该使用OrderedDict的哪个实现?

python - pygame 跳过更新屏幕

django - 如何增加显示在 Django 模板中的年份范围?

python - Django Rest 框架文件上传

Python 解码 "\u041b"字符串

python - 如何让 LBForum (0.9.22) 运行