帐户激活django_registration_email出错

时间:2014-01-30 08:51:00

标签: python django django-registration

我使用django_registration和django_registration电子邮件在我的应用程序上实现了身份验证。这是我的代码:

settings.py

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',

#custom apps
'order',
'fiesta',

#3rd party apps
'south',
'jquery',
'djangoformsetjs',

# DEVELOPER TOOLS
'debug_toolbar',
#authentication apps
'registration',
'registration_email',

#DJANGO REGISTRATION SETTINGS

ACCOUNT_ACTIVATION_DAYS = 7 # one week activation window

AUTHENTICATION_BACKENDS = (
'registration_email.auth.EmailBackend',
)

LOGIN_REDIRECT_URL = '/'

urls.py

urlpatterns = patterns('',
url(r'^$', lambda x:HttpResponseRedirect("/fiesta/workspace/"), name="home"),
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration_email.backends.default.urls')),
url(r'^fiesta/', include('fiesta.urls')),

注册电子邮件发送正常但是当我点击帐户激活链接时,这是我得到的错误:

Traceback:
File "/home/blaqx/.virtualenv/django5/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115.response = callback(request, *callback_args, **callback_kwargs)
File "/home/blaqx/.virtualenv/django5/lib/python2.7/site-packages/django/views/generic/base.py" in view
68.return self.dispatch(request, *args, **kwargs)
File "/home/blaqx/.virtualenv/django5/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
86.return handler(request, *args, **kwargs)
File "/home/blaqx/.virtualenv/django5/lib/python2.7/site-packages/registration/views.py" in get
126.success_url = self.get_success_url(request, activated_user)

Exception Type: TypeError at /accounts/activate/bf93e2619ad0b7419b34dc0284e172fae8ecafef/
Exception Value: 'str' object is not callable

在错误中,我可以看到在帐户激活期间,正在引用django-registration而不是django-registration-email。但是我不知道这是错误的原因以及如何解决它。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

首先,您使用两个包用于相同的目的(即发送电子邮件激活),这是包装,

  1. django的登记的电子邮件
  2. django-registration
  3. 从上面选择一个包。我选择django-registration,这里是文档https://django-registration.readthedocs.org

    按照代码说明进行操作

    <强> settings.py

    INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    
    #custom apps
    'order',
    'fiesta',
    
    #3rd party apps
    'south',
    'jquery',
    'djangoformsetjs',
    
    # DEVELOPER TOOLS
    'debug_toolbar',
    #authentication apps
    'registration',
    #'registration_email',
    )
    
    #DJANGO REGISTRATION SETTINGS
    
    ACCOUNT_ACTIVATION_DAYS = 7 # one week activation window
    
    #AUTHENTICATION_BACKENDS = (
    #'registration_email.auth.EmailBackend',
    #)
    
    LOGIN_REDIRECT_URL = '/'
    

    <强> urls.py

    urlpatterns = patterns('',
    url(r'^$', lambda x:HttpResponseRedirect("/fiesta/workspace/"), name="home"),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/', include('registration.backends.default.urls')),
    url(r'^fiesta/', include('fiesta.urls')),
    )