首页 > python > Django 2.0中“django.core.xheaders”的替代Django包

Django 2.0中“django.core.xheaders”的替代Django包 (Alternative Django package for “django.core.xheaders” in Django 2.0)

问题

我正在将一个旧Django项目迁移到Django 2.0。在其中一个视图文件中,我遇到了一个import声明:

from django.core.xheaders import populate_xheaders

我试图弄清楚这个软件包的替代方案 - 无论是在Google还是在stackoverflow中

任何人都可以帮我找到替代包吗?

解决方法

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

django.contrib.flatpages应用程序用于设置自定义HTTP标头以进行调试。此功能未记录,并且使缓存无效,因此已将其删除,以及之前可用的通用实现django.core.xheaders

我怀疑你可以在你正在移植的应用程序中删除对此功能的调用。

如果确实需要这些标头,则可以从提交它的位置复制功能。

有关最初创建此功能的原因的信息,请查阅跟踪其添加的故障单

问题

I'm migrating an old Django project to Django 2.0. In one of view files, I came across an import statement:

from django.core.xheaders import populate_xheaders

I'm trying to figure out the alternatives of this packages - neither in google nor in stackoverflow.

Can anyone help me find the alternative package?

解决方法

django.core.xheaders was removed in Django 1.6. The following message was added to the docs upon its removal:

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.

I suspect you may be able to remove the call to this function in the app you're porting.

If you do need these headers, you could copy the functionality from the commit where it was removed.

For information on why this function was initially created, consult the ticket that tracked its addition.

相似信息