【发布时间】:2017-02-23 08:42:18
【问题描述】:
我有一个用于测试 Django 的开发环境。我从“本地”pyenv 安装运行 Python 3.5.2。我有 Django 1.10.2。我昨天发现了allauth 注册插件,并且一直在使用它,但遇到了问题。
我的网站是“dev.my.domain.com”。目的是在本网站的生产版本上不会有任何“公开”信息。生产版本将被称为:“members.my.domain.com”。所以,我想知道“allauth”插件是否有可能让所有非/adomn入站请求检查身份验证?
所以,请求:
- dev.my.domain.com
- dev.my.domain.com/foo
- dev.my.domain.com/foo/../bar/...
都应该检查身份验证。如果不在那里,那么我假设“allauth”将重定向到登录/注册页面。
我尝试将Members/urls.py 文件设置为:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^$', include('allauth.urls')),
url(r'^admin/', admin.site.urls),
]
但该炸弹会出现页面未找到错误和DEBUG 消息:
Using the URLconf defined in Members.urls, Django tried these URL patterns, in this order:
^$ ^ ^signup/$ [name='account_signup']
^$ ^ ^login/$ [name='account_login']
^$ ^ ^logout/$ [name='account_logout']
^$ ^ ^password/change/$ [name='account_change_password']
^$ ^ ^password/set/$ [name='account_set_password']
^$ ^ ^inactive/$ [name='account_inactive']
^$ ^ ^email/$ [name='account_email']
^$ ^ ^confirm-email/$ [name='account_email_verification_sent']
^$ ^ ^confirm-email/(?P<key>[-:\w]+)/$ [name='account_confirm_email']
^$ ^ ^password/reset/$ [name='account_reset_password']
^$ ^ ^password/reset/done/$ [name='account_reset_password_done']
^$ ^ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
^$ ^ ^password/reset/key/done/$ [name='account_reset_password_from_key_done']
^$ ^social/
^$ ^google/
^$ ^facebook/
^$ ^facebook/login/token/$ [name='facebook_login_by_token']
^admin/
The current URL, , didn't match any of these.
我向自己的无知低头,回到 allauth 文档并使用他们默认的 urls 设置:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^accounts/', include('allauth.urls')),
url(r'^admin/', admin.site.urls),
]
但这也会引发页面未找到和不同的消息:
Using the URLconf defined in Members.urls, Django tried these URL patterns, in this order:
^accounts/
^admin/
The current URL, , didn't match any of these.
我认为“allauth”安装的其余部分已正确完成,但我遗漏了一些东西。
想法?
【问题讨论】:
标签: python django django-allauth