且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何配置在 Django 中注销后重定向的位置?

更新时间:2023-12-02 13:11:46

Modern Django (2017+?) 有一个名为 LOGOUT_REDIRECT_URL 的设置.

Modern Django (2017+?) has a setting called LOGOUT_REDIRECT_URL.

您不需要覆盖或包装任何东西.

You don't need to overwrite or wrap anything.

根据文档,您可以只向注销视图提供 next_page 参数.https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.views.logout

According to the docs, you can just supply the next_page argument to the logout view. https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.views.logout

(r'^logout/$', 'django.contrib.auth.views.logout',
                          {'next_page': '/successfully_logged_out/'})