gpt4 book ai didi

python - 将 success_url 传递给激活

转载 作者:太空宇宙 更新时间:2023-11-03 13:24:05 24 4
gpt4 key购买 nike

文档说:

 ``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_activation_complete 的 URL 模式。参见 Naming URL patterns在 Django 文档中。

关于python - 将 success_url 传递给激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3808241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com