Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango-registration activate account but template shows error in activation
    primarykey
    data
    text
    <p>I am new to Django and I included django-registration to my project.</p> <p>It works great except that when a user click on the activation link, his accounts is activated but the user is redirected to a template that says otherwise.</p> <p>Here is the urls.py part : </p> <pre><code>urlpatterns = patterns('', url(r'^activate/complete/$', direct_to_template, {'template': 'registration/activation_complete.html'}, name='registration_activation_complete'), url(r'^activate/(?P&lt;activation_key&gt;\w+)/$', activate, {'backend': 'registration.backends.default.DefaultBackend'}, name='registration_activate'), </code></pre> <p>Here is the view part : </p> <pre><code>def activate(request, backend, template_name='registration/activate.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) </code></pre> <p>The line :</p> <pre><code>backend.post_activation_redirect </code></pre> <p>returns registration_activation_complete</p> <p>And here is the template :</p> <pre><code>{% extends "base.html" %} {% load i18n %} {% block content %} {% if account %} &lt;p&gt;{% trans "Account successfully activated" %}&lt;/p&gt; &lt;p&gt;&lt;a href="{% url auth_login %}"&gt;{% trans "Log in" %}&lt;/a&gt;&lt;/p&gt; {% else %} &lt;p&gt;{% trans "Account activation failed" %}&lt;/p&gt; {% endif %} {% endblock %} </code></pre> <p>What I suspect is that it creates the account then gets redirected to another url thanks to the line :</p> <pre><code>return redirect(to, *args, **kwargs) </code></pre> <p>Then it calls the generic views direct_to_template but at this moment the variable account does not exist anymore since it was destroyed after the redirection (that's my guess).</p> <p>I would like to send the account variable to the second view but did not manage to do it.</p> <p>Thank you for your help with this problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload