python – 将success_url传递给activate
发布时间:2020-12-20 11:15:31 所属栏目:Python 来源:网络整理
导读:文件说: ``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. 我该怎么做 ? 解决方法 您可
文件说:
``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中执行此操作,例如:
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应使用registration_activation_complete的URL模式.请参阅Django文档中的Naming URL patterns. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |