将 success_url 传递给激活

发布于 2024-09-25 07:22:20 字数 273 浏览 5 评论 0原文

文档说:

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

我该怎么做?

Docs say :

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

How can I do it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北渚 2024-10-02 07:22:20

您可以在 urls.py 中执行此操作,例如:

url(r'^account/activate/(?P<activation_key>\w+)/

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

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 文档中的命名 URL 模式

, 'registration.views.activate', {'success_url': 'registration_activation_complete'}, name='registration_activate'), url(r'^account/activate/success/

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


最简单的解决方案是仅命名django-registration 应使用 registration_activation_complete 的 URL 模式。请参阅 Django 文档中的命名 URL 模式

, direct_to_template, {'template': 'registration/activation_complete.html', name='registration_activation_complete'),

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

最简单的解决方案是仅命名django-registration 应使用 registration_activation_complete 的 URL 模式。请参阅 Django 文档中的命名 URL 模式

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

url(r'^account/activate/(?P<activation_key>\w+)/

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.

, 'registration.views.activate', {'success_url': 'registration_activation_complete'}, name='registration_activate'), url(r'^account/activate/success/

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


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.

, 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文