使用Django handler404中断Wagtail重定向 [英] Using Django handler404 breaks Wagtail redirects

查看:38
本文介绍了使用Django handler404中断Wagtail重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义404处理程序,可用于运行CMS Wagtail的Django应用程序.用我选择的视图函数替换Django handler404,一切都很好.除了似乎破坏了Wagtails 301重定向功能.我现在所有的重定向都只是转到404页面.以下是我在基本应用中使用handler404的方式,

I have a custom 404 handler that I use for my Django app running the CMS Wagtail. Everything works great with replacing the Django handler404 with a view function of my choosing. Except that it seems to break Wagtails 301 redirect feature. All of the redirects I have now just go to a 404 page. Below is how I am using handler404 in the base app,

handler404 = siteapp_views.handler404

推荐答案

您的404处理程序必须返回带有 status_code = 404 的响应,否则Wagtail重定向中间件将无法工作.

Your 404 handler must return a response with status_code=404, otherwise the Wagtail redirect middleware will not work.

这篇关于使用Django handler404中断Wagtail重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆