本文整理汇总了Python中User.models.User.save方法的典型用法代码示例。如果您正苦于以下问题:Python User.save方法的具体用法?Python User.save怎么用?Python User.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User.models.User
的用法示例。
在下文中一共展示了User.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from User.models import User [as 别名]
# 或者: from User.models.User import save [as 别名]
def save(self):
user = User()
user.username = self.username
user.set_password(self.password)
user.email = self.email
if self.signature:
user.signature = self.signature
user.save()
return user
示例2: user_signup_save
# 需要导入模块: from User.models import User [as 别名]
# 或者: from User.models.User import save [as 别名]
def user_signup_save(request):
fname = request.POST.get('fname')
lname = request.POST.get('lname')
email = request.POST.get('email')
password = request.POST.get('password')
user = User(fname=fname, lname=lname, email=email,
last_login=datetime.now())
user.set_password(password)
#force_insert=True forces the database to do an insert rather then an update
status = user.save(force_insert=True)
if status == 'success':
subject = 'Welcome to PLTL'
with open("templates/SignUpNotification.txt", "r") as data:
msgbody = data.read()
msg = 'Dear ' + fname +',\n' + msgbody
from_mail = settings.EMAIL_HOST_USER
send_mail(subject, msg, from_mail, [email, from_mail],
fail_silently=True)
return redirect('home')