本文整理汇总了Python中cards.forms.EmailUserCreationForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python EmailUserCreationForm.is_valid方法的具体用法?Python EmailUserCreationForm.is_valid怎么用?Python EmailUserCreationForm.is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cards.forms.EmailUserCreationForm
的用法示例。
在下文中一共展示了EmailUserCreationForm.is_valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import is_valid [as 别名]
def register(request):
if request.method == 'POST':
form = EmailUserCreationForm(request.POST)
if form.is_valid():
form.save()
return redirect("profile")
else:
form = EmailUserCreationForm()
return render(request, "registration/register.html", {
'form': form,
})
示例2: register
# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import is_valid [as 别名]
def register(request):
if request.method == "POST":
form = EmailUserCreationForm(request.POST)
if form.is_valid():
form.save()
# text_content = 'Thank you for signing up for our website, {}'.format(user.username)
# html_content = '<h2>Thanks {} for signing up!</h2> <div>I hope you enjoy using our site</div>'
# .format(user.username)
# msg = EmailMultiAlternatives("Welcome!", text_content, settings.DEFAULT_FROM_EMAIL, [user.email])
# msg.attach_alternative(html_content, "text/html")
# msg.send()
return redirect("profile")
else:
form = EmailUserCreationForm()
return render(request, "registration/register.html", {"form": form})
示例3: register
# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import is_valid [as 别名]
def register(request):
if request.method == 'POST':
form = EmailUserCreationForm(request.POST)
if form.is_valid():
user = form.save()
text_content = 'Thank you for signing up for our website, {} {}!'.format(user.first_name, user.last_name)
html_content = '<h2>Thanks {} {} for signing up!</h2> <div>I hope you enjoy using our site</div>' \
'<p>You signed up at {}.</p>'.format(user.first_name, user.last_name, user.date_joined)
msg = EmailMultiAlternatives("Welcome!", text_content, settings.DEFAULT_FROM_EMAIL, [user.email])
msg.attach_alternative(html_content, "text/html")
msg.send()
return redirect("profile")
else:
form = EmailUserCreationForm()
return render(request, "registration/register.html", {
'form': form,
})