文档说:

 ``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.

我该怎么办呢?

有帮助吗?

解决方案

您可以做到这一点在你的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'),

另一种方法是通过从默认后端继承来创建自己的后端(这是简单的比它听起来):

from registration.backends.default import DefaultBackend

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

最简单的解决方法就是名称Django的注册应该使用registration_activation_complete你的URL模式。请参见命名URL模式在Django的文档

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top