我试图了解 django-registration 应用程序,现在我能够使用激活密钥向用户发送电子邮件。我无法弄清楚当用户单击他/她的电子邮件中的链接时如何将激活密钥发送回服务器。
class AbstractEmailUser(AbstractBaseUser, PermissionsMixin):
.....
.....
def send_activation_email(self, email):
email = email
ctx_dict = { 'activation_key' : self.activation_key,
'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
}
subject = render_to_string('activation_email_subject.txt', ctx_dict)
subject = ''.join(subject.splitlines())
message = render_to_string('activation_email.txt', ctx_dict)
send_mail(subject, message, 'gccFishing.com', [email], fail_silently = False)
def activate(self, activation_key):
if SHA1_RE.search(activation_key):
try:
self.get(activation_key = activation_key)
except:
self.model.DoesNotExist
return False
if not self.activation_key_expired():
self.is_active = True
self.activation_key = self.model.ACTIVATED
self.save()
return self
return False
activation_email.txt
创建调用activate method
with的链接应该放入什么代码activation_key
?或者有更好的方法吗?
任何帮助都会很棒。谢谢