django:URL 调度程序 ->无限循环
urlpatterns = patterns('',
#(r'admin/main/report/', main_page_redirect),
(r'^admin/', include(admin.site.urls)),
(r'^', main_page_redirect),
)
def main_page_redirect(request):
return HttpResponseRedirect('/admin/main/report/?e=+2')
然后当我尝试访问 /localhost 时,它就会变成无限循环。 有谁知道如何解决它?
urlpatterns = patterns('',
#(r'admin/main/report/', main_page_redirect),
(r'^admin/', include(admin.site.urls)),
(r'^', main_page_redirect),
)
def main_page_redirect(request):
return HttpResponseRedirect('/admin/main/report/?e=+2')
then when i try to go to /localhost then it becomes a infinite loop.
does anyone knows how to slove it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
settings.py 中的 LOGIN_URL 设置为什么?管理站点可能会尝试将您重定向到登录页面,该页面可能会重定向到管理站点。只是一个想法。
what is your LOGIN_URL in settings.py set to? The admin site could be trying to redirect you to your login page, which could be the page that is redirecting to the admin site. Just an idea.
我能够通过没有映射到 admin/main/report/ 的视图来重新创建同样的事情。
我不知道为什么,但如果您创建一个视图并取消注释 admin/main/report/ 的 urlpattern (并且不对该视图使用 main_page_redirect ,那么您应该可以开始。
这是我的示例:
I was able to recreate this same thing by not having a view mapped to admin/main/report/.
I'm not sure why, but if you create a view and uncomment your urlpattern for admin/main/report/ (and do not use main_page_redirect for that view, you should be good to go.
Here is my example: