我尝试关注最新的http://django-allauth.readthedocs.org/en/latest/#installation
urls.py
文件如下:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('allauth.urls')),
)
settings.py
文件有:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
)
TEMPLATE_CONTEXT_PROCESSORS = (
# Required by allauth template tags
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
)
SITE_ID = 1
然后我跑了python manage.py syncdb
但是当我访问我的localhost:8000 / accounts / login /时,它给了我找不到页面(404)。我还仔细检查了我在教程中所做的事情:http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/但我不知道还有什么可以让基本登录屏幕显示出来。有什么指针吗?
修改
除了Page Not Found 404
之外,还有页面上的错误Using the URLconf defined in asa.urls, Django tried these URL patterns, in this order:
^admin/
^accounts/ ^ ^signup/$ [name='account_signup']
^accounts/ ^ ^login/$ [name='account_login']
^accounts/ ^ ^logout/$ [name='account_logout']
^accounts/ ^ ^password/change/$ [name='account_change_password']
^accounts/ ^ ^password/set/$ [name='account_set_password']
^accounts/ ^ ^inactive/$ [name='account_inactive']
^accounts/ ^ ^email/$ [name='account_email']
^accounts/ ^ ^confirm-email/$ [name='account_email_verification_sent']
^accounts/ ^ ^confirm-email/(?P<key>\w+)/$ [name='account_confirm_email']
^accounts/ ^ ^confirm_email/(?P<key>\w+)/$
^accounts/ ^ ^password/reset/$ [name='account_reset_password']
^accounts/ ^ ^password/reset/done/$ [name='account_reset_password_done']
^accounts/ ^ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
^accounts/ ^ ^password/reset/key/done/$ [name='account_reset_password_from_key_done']
^accounts/ ^social/
当前网址(accounts / profile /)并不匹配其中任何一个。
答案 0 :(得分:21)
要检查一下:你启动了服务器吗?
python manage.py runserver
编辑:
看起来您正在尝试accounts/profile/
,这不是注册的网址。如果你转到localhost:8000/accounts/register
,它仍然会出错?
另外,来自docs:
当我尝试登录时,我遇到了/ accounts / profile / 上的404
当你在这里结束时,你已经成功登录。但是,你需要自己实现这个URL的视图,因为这里显示的是项目特定的。您也可以决定在其他地方重定向。
您似乎需要为accounts / profile /
编写自己的视图如果需要,您可以将登录重定向设置为settings.py
中的其他页面。即:
LOGIN_REDIRECT_URL = "/"
这会将您送回主页。