【问题标题】:Page not found (404)找不到页面 (404)
【发布时间】:2013-06-28 18:44:20
【问题描述】:

错误:

Request Method: GET
Request URL:    http://192.168.100.10/accounts/profile/
Using the URLconf defined in urls, Django tried these URL patterns, in this order:
^collect/
^member/
^accounts/login/$
^ ^$
^ ^contact/$
^ ^privacy-statement/$
^logout/$ [name='logout']
^data-admin/doc/
^accounts/password/reset/$
^accounts/password/reset/done/$
^accounts/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$
^accounts/password/done/$
^media/(?P<path>.*)$
The current URL, accounts/profile/, didn't match any of these.

登录后出现此错误,它正在接受用户名和密码,它应该成功进入/index/页面,但它正在进入accounts/profile/。如果我删除accounts/profile/并运行ip,它正在重定向到正确的网址。

应用 urls.py

from django.conf.urls.defaults import *

urlpatterns = patterns(
    'zergit.views',
    (r'^$', 'index'),
  )

谢谢

【问题讨论】:

    标签: django django-models django-templates django-admin django-views


    【解决方案1】:

    您需要更改默认的LOGIN_REDIRECT_URL 设置

    默认情况下,LOGIN_REDIRECT_URL 设置为 /accounts/profile/。您的 URL 中显然没有 /accounts/profile/,因此您需要指定登录成功后要重定向到的 URL。

    类似:

    LOGIN_REDIRECT_URL = '/' #Or whatever you wish
    

    【讨论】:

      【解决方案2】:

      如果您不想更改 LOGIN_REDIRECT_URL 设置,只需使用帐户登录 URL 中的“下一个”参数和值即可重定向到您想要的位置。例如,OP 可以将请求的登录 url 指定为“http://192.168.100.10/accounts/login/?next=/index/

      【讨论】:

        猜你喜欢
        • 2016-08-01
        • 2016-08-01
        • 2015-10-22
        • 2014-03-20
        • 2020-10-27
        • 2019-07-21
        • 2020-07-14
        • 2019-12-02
        相关资源
        最近更新 更多