def send_user_confirmation(self, request):
"""
Called after user completes initial registration form.
Generate a confirmation key, then
send an email to the associated user with a link (containing the key)
to a form allowing them to set their password and confirm their identity.
"""
# Generate and set a random confirmation key
self.confirmation_key = get_random_string(length=20, allowed_chars='0123456789')
self.save()
# Use appropriate email templates to generate and send the email
context = {
"site": get_current_site(request),
"conf_key": self.confirmation_key,
}
self.user.email_user(
render_to_string("registration/confirmation_email_subject.txt", context=context),
render_to_string("registration/confirmation_email.html", context=context),
html_message=render_to_string("registration/confirmation_email.html", context=context),
)
评论列表
文章目录