registration 0.8 alpha activation problem
Posted
by
craphunter
on Stack Overflow
See other posts from Stack Overflow
or by craphunter
Published on 2011-01-02T20:02:21Z
Indexed on
2011/01/02
20:53 UTC
Read the original article
Hit count: 399
Got the following error:
Exception Type: TypeError at /accounts/account/activate/success/
Exception Value: activate() takes at least 2 non-keyword arguments (1 given)
My view:
def activate(request, backend,
template_name='registration/activation_complete.html',
success_url=None, extra_context=None, **kwargs):
backend = get_backend(backend)
account = backend.activate(request, **kwargs)
if account:
if success_url is None:
to, args, kwargs = backend.post_activation_redirect(request, account)
return redirect(to, *args, **kwargs)
else:
return redirect(success_url)
if extra_context is None:
extra_context = {}
context = RequestContext(request)
for key, value in extra_context.items():
context[key] = callable(value) and value() or value
return render_to_response(template_name,
kwargs,
context_instance=context)
My url:
urlpatterns = patterns('',
url(r'^activate/complete/$',
direct_to_template,
{ 'template': 'registration/activation_complete.html' },
name='registration_activation_complete'),
# Activation keys get matched by \w+ instead of the more specific
# [a-fA-F0-9]{40} because a bad activation key should still get to the view;
# that way it can return a sensible "invalid key" message instead of a
# confusing 404.
url(r'^activate/(?P<activation_key>\w+)/$',
activate,
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_activate'),
url(r'^register/$',
register,
{ 'backend': 'registration.backends.default.DefaultBackend' },
name='registration_register'),
url(r'^register/complete/$',
direct_to_template,
{ 'template': 'registration/registration_complete.html' },
name='registration_complete'),
url(r'^register/closed/$',
direct_to_template,
{ 'template': 'registration/registration_closed.html' },
name='registration_disallowed'),
(r'', include('registration.auth_urls')),
url(r'^account/activate/(?P<activation_key>\w+)/$', 'registration.views.activate', {'success_url': 'account/activate/success/'}, name='registration_activate2'),
url(r'^account/activate/success/$', direct_to_template, {'template': 'registration/activation_complete.html'}, name='registration_activation_complete'),
)
What do I do wrong?
Thanks!
© Stack Overflow or respective owner