Question

I've implemented authentication on my application using django_registration and django_registration email. Here is my code:

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')),

)

The registration email is sent okay but when i click on the account activation link, here is the error i get:

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

In the error, I can see that during account activation, a reference is being made to django-registration instead of django-registration-email. I however don't know if this is the cause of the error and how to solve it. Any help will be greatly appreciated.

Was it helpful?

Solution

First you are using two packages for same purpose(i.e; sending the email activation), Here the packeges,

  1. django-registration-email
  2. django-registration

Select the one package from above. I choose django-registration, Here the doc https://django-registration.readthedocs.org.

And follow the code instructions,

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')),
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top