我使用非标准注册程序。基本上,Web管理员注册用户,然后向用户发送一封电子邮件,其中包含密码重置。我想将有关密码重置是否发生的信息告知网络管理员,但似乎在官方Django文档中找不到任何内容。有人知道这是否可能吗?预先感谢。
根据要求输入代码:
def create_account(request, pk):
# Part 1: create an account for the client
invitation_email = request.POST.get("email", "")
individual = get_object_or_404(Individual, id=pk)
user = User.objects.create_user(create_username(individual), invitation_email, random_password(50))
user.is_active = True # It needs to be this way for the password reset to work
user.save()
individual.account = user
individual.save()
form = PasswordResetForm({'email': user.email}) #user_email
if form.is_valid():
request = HttpRequest()
request.META['SERVER_NAME'] = '127.0.0.1:8000'
request.META['SERVER_PORT'] = '80'
form.save(
request = request,
#use_https= True, #if True, PORT = 443
from_email = DEFAULT_FROM_EMAIL,
email_template_name='registration/password_reset_email.html'
)
next = request.POST.get('next', '/')
return HttpResponseRedirect(next)