Page not found (404)

不想你离开。 提交于 2019-12-13 12:28:20

问题


Error:

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.

This error occurs after login,it is accepting user name and password and it should successfully take to /index/ page but it is taking to accounts/profile/.If i remove the accounts/profile/ and run the ip,it is redirecting to the correct urls.

app urls.py

from django.conf.urls.defaults import *

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

Thanks


回答1:


You need to change the default LOGIN_REDIRECT_URL settings

By default, LOGIN_REDIRECT_URL is set to /accounts/profile/. You clearly dont have a /accounts/profile/ in your URLs, so you need to specify which URL you want to be redirected to once the login is successful.

Something like:

LOGIN_REDIRECT_URL = '/' #Or whatever you wish



回答2:


If you don't want to change the LOGIN_REDIRECT_URL setting, just use the 'next' parameter and value in your account login url to redirect where ever you want. For example, the OP could have specified the requested login url as "http://192.168.100.10/accounts/login/?next=/index/"



来源:https://stackoverflow.com/questions/17407971/page-not-found-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!