当我尝试访问django-registration时,django获得了404页面

时间:2012-02-27 17:44:26

标签: django django-registration django-profiles

您好,并提前感谢您,

当我安装django-profiles和django-registration时。我相信我正确地遵循了如何配置它们的教程:

http://agiliq.com/books/djenofdjango/chapter5.html#reusable-apps

现在,当我尝试访问website.com/accounts时,我收到了404页面:

使用acme_p.urls中定义的URLconf,Django按以下顺序尝试了这些URL模式:

^$
^accounts/
^admin/doc/
^admin/

当前网址帐户与这些网址中的任何一个都不匹配。

我的网址文件如下所示:

#acme_p urls - Django Project

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',

    url(r'^$', include('user_prof.urls')),

    # Examples:
    # url(r'^$', 'acme_p.views.home', name='home'),
    # url(r'^acme_p/', include('acme_p.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

user_prof urls.py - 上面提到的项目下面的Django App

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^login/$', 'auth.views.login_user'),
    (r'^accounts/', include('registration.urls')),
#    (r'^accounts/', include('registration.backends.default.urls')),

)

谢谢你的帮助。

DP

2 个答案:

答案 0 :(得分:2)

(r'^accounts/', include('registration.urls')),应位于根urls.py中,而不是应用程序urls.py

答案 1 :(得分:1)

配置中没有website.com/account,只有website.com/account/(more)其中(更多)具有给django-registration模块的其余网址。例如,您可以尝试website.com/account/login/来检查django-registration模块是否正常工作。

此外,您应该将它们放在根urls.py文件上。