我的django-registration有问题。一切正常,直到我强制使用独特的电子邮件。
我有非常基本的应用程序骨架。这很好用:
auth_patterns = [
url(r'^', include('registration.backends.hmac.urls')),
]
urlpatterns = i18n_patterns(
url(r'^admin/', admin.site.urls),
url(r'^$', login_required(HomeView.as_view()), name='index'),
url(r'^accounts/', include(auth_patterns)),
)
但是当我添加
时url(r'^register/$',
RegistrationView.as_view(form_class=RegistrationFormUniqueEmail),
name='registration_register'
),
在auth_patterns中我在邮件上获得激活链接
http://localhost:8000/en/accounts/activate/98a3585128c1b6899e4493768d4e62a52764fc5f/
但点击后我得到了
Account activation failed
来自我的模板(activate.html)
我在浏览器控制台/或./manage.py runserver输出中没有错误,没有。当我尝试调试注册插件时,我注意到注册插件在此代码中将用户返回为None(registration.backends.hmac.views.ActivationView):
def validate_key(self, activation_key):
"""
Verify that the activation key is valid and within the
permitted activation time window, returning the username if
valid or ``None`` if not.
"""
try:
username = signing.loads(
activation_key,
salt=REGISTRATION_SALT,
max_age=settings.ACCOUNT_ACTIVATION_DAYS * 86400
)
return username
# SignatureExpired is a subclass of BadSignature, so this will
# catch either one.
except signing.BadSignature:
return None
它抛出BadSignature,但为什么呢?有人有这个问题吗?如何解决?
答案 0 :(得分:1)
我很感激它已经被移动了。我正在使用django-registration == 2.3
跟随urls.py,它应该有效:
来自registration.backends.hmac.views的导入RegistrationView 来自registration.forms import RegistrationFormUniqueEmail
类RegistrationViewUniqueEmail(RegistrationView): form_class = RegistrationFormUniqueEmail
... urlpatterns = i18n_patterns(
url(r'^accounts/register/$', RegistrationViewUniqueEmail.as_view(), name='registration_register'),
url(r'^accounts/', include('registration.backends.hmac.urls')),