django admin登录后重定向到另一个页面 [英] Redirecting to another page after django admin login
本文介绍了django admin登录后重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
然而在/ admin /.
解决方案
成功登录后,我找不到将用户重定向到自定义网址的方式同样的问题。
而不是在登录后重定向 我使用@staff_member_required装饰器
作为我的视图 / my-url /
,其重定向到管理员登录
from django.contrib.admin.views.decorators import staff_member_required
@staff_member_required
def test_list(request):
return HttpResponse('TEST')
如果使用基于类的视图来查看 method_decorator
I am making a custom administration page in Django. I do not want to reinvent the wheel and thus want to use Django admin login form for the staff to log in and redirect them to /my-url/ afterwards.
However, I can't find the way to redirect user to a custom url after successful login at /admin/.
解决方案
I had the same issue.
Instead of redirect after login I used the @staff_member_required decorator
for my view /my-url/
which redirects to the admin login
from django.contrib.admin.views.decorators import staff_member_required
@staff_member_required
def test_list(request):
return HttpResponse('TEST')
If class based views is used check out the method_decorator
这篇关于django admin登录后重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文