2010-09-27 79 views
3

文件說:通行證success_url於激活

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

我該怎麼辦呢?

回答

7

你可以在你的urls.py,如:

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 

最簡單的解決方案是僅命名您的URL模式,django註冊應使用registration_activation_complete。請參閱Django文檔中的Naming URL patterns