开发者

Pass success_url to the activate

Docs say :

 ``success_url``
    The name of a URL pattern to redirect to on successful
    acivation. This is opt开发者_如何学Goional; if not specified, this will be
    obtained by calling the backend's
    ``post_activation_redirect()`` method.

How can I do it ?


You can do it in your urls.py, e.g.:

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

The other approach is to create your own backend (which is simpler than it sounds) by inheriting from the default backend:

from registration.backends.default import DefaultBackend

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

The easiest solution is to just name your URL pattern that django-registration should use registration_activation_complete. See Naming URL patterns in the Django docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜