Frage

Docs sagen:

 ``success_url``
    The name of a URL pattern to redirect to on successful
    acivation. This is optional; if not specified, this will be
    obtained by calling the backend's
    ``post_activation_redirect()`` method.

Wie kann ich es tun?

War es hilfreich?

Lösung

Sie können es in Ihrem urls.py tun, z.

url(r'^account/activate/(?P<activation_key>\w+)/$', 'registration.views.activate', {'success_url': 'registration_activation_complete'}, name='registration_activate'),
url(r'^account/activate/success/$', direct_to_template, {'template': 'registration/activation_complete.html', name='registration_activation_complete'),

Der andere Ansatz ist Ihr eigenes Backend zu erstellen (das ist einfacher als es klingt) durch aus dem Standard-Backend vererben:

from registration.backends.default import DefaultBackend

class MyRegistrationBackend(DefaultBackend):
    def post_activation_redirect(self, request, user):
        # return your URL here

Die einfachste Lösung ist nur Ihr URL-Muster Namen, die django-Registrierung registration_activation_complete verwenden sollte. Siehe Naming URL-Muster in dem Django docs .

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top