logo4 Evolution is progress—                          
progress is creativity.        
vline

Django Registration Bug

The bug in django registration module that I'm going to report is not actually a bug, but a failure of smoth interaction between the registration templates and the default backend.

After successful registration and email activation the template always reports

Account activation failed

Even if activation was successful and the module, and the user can properly log in the next time.

The reason is because the account variable that is used in the template is not set by the backend.

{% if account %}
<p>{% trans "Account successfully activated" %}</p>
<p><a href="{% url auth_login %}">{% trans "Log in" %}</a></p>
{% else %}
<p>{% trans "Account activation failed" %}</p>
{% endif %}

You may simply ignore this fact and redirect the user to the login page where his/her next login fails if not properly activated. But there exists a more elegant solution to the problem.

The account variable has to be forwarded to the page by adding {'account':user}

def post_activation_redirect(self, request, user):
        """
        Return the name of the URL to redirect to after successful
        account activation.
        
        """
        return ('registration_activation_complete', (), {'account':user})

Now as the activation-complete page is called via direct_to_template, we need to modify the templeta a bit. That is instead of retrieving account we have to use the variable params.account.

{% if params.account %}
<p>{% trans "Account successfully activated" %}</p>
<p><a href="{% url auth_login %}">{% trans "Log in" %}</a></p>
{% else %}
<p>{% trans "Account activation failed" %}</p>
{% endif %}

After accomplishing these little amendments the activation works as expected. Studying the documentation of the registration module was useful in solving this problem.


Tags: Software

 
   

(c) Mato Nagel, Weißwasser 2004-2013, Disclaimer