アクティブにするためにsuccess_urlを渡します
-
25-09-2019 - |
質問
文書は言います:
``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
最も簡単な解決策は、ちょうどジャンゴ登録はregistration_activation_complete
を使用する必要があることを、あなたのURLパターンに名前を付けることです。 は、DjangoのドキュメントにこのURLパターンに名前を付けるを参照してください。ます。
所属していません StackOverflow