本文整理汇总了Python中eventex.subscriptions.forms.SubscriptionForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python SubscriptionForm.save方法的具体用法?Python SubscriptionForm.save怎么用?Python SubscriptionForm.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eventex.subscriptions.forms.SubscriptionForm
的用法示例。
在下文中一共展示了SubscriptionForm.save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return direct_to_template(request, "subscriptions/subscription_form.html", {"form": form})
obj = form.save()
return HttpResponseRedirect("/inscricao/%d/" % obj.pk)
示例2: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request, 'subscriptions/subscription_form.html',
{'form': form})
obj = form.save()
return HttpResponseRedirect('/inscricao/%d/' % obj.pk)
示例3: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request, 'subscriptions/inscricao.html', {'form': form})
obj = form.save()
return HttpResponseRedirect(r('subscriptions:detail', args=[obj.pk]))
示例4: subscribe
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def subscribe(request):
if request.method == 'POST':
form = SubscriptionForm(request.POST)
if not form.is_valid():
return direct_to_template(request, 'subscriptions/subscription_form.html', {'form':form})
obj = form.save()
return HttpResponseRedirect('/inscricao/%d/' % obj.pk)
else:
return direct_to_template(request, 'subscriptions/subscription_form.html', {'form':SubscriptionForm()})
示例5: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request, 'subscriptions/subscriptions_form.html', {'form': form})
subscription = form.save()
_send_mail(subscription)
return HttpResponseRedirect(r('subscriptions:detail', subscription.uuid))
示例6: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
data = {'form': form}
return render(request,
template,
data)
obj = form.save()
url = reverse('subscription:detail', args=(obj.id,))
return HttpResponseRedirect(url)
示例7: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request,'subscriptions/subscription_form.html', {'form': form})
subscription = form.save()
_send_mail({'subscription': subscription},
settings.DEFAULT_FROM_EMAIL,
'Confirmação de inscrição',
'subscriptions/subscription_email.txt',
subscription.email)
return HttpResponseRedirect(r('subscriptions:detail', subscription.pk))
示例8: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
"""
Requests with POST data need to be handled as creation.
"""
form = SubscriptionForm(request.POST)
if form.is_valid():
obj = form.save()
return HttpResponseRedirect('/inscricao/%d/' % obj.pk)
else:
return render(
request,
'subscriptions/subscription_form.html',
{'form': form}
)
示例9: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request, "subscriptions/subscription_form.html", {"form": form})
subscription = form.save()
_send_mail(
"Confirmação de inscrição",
settings.DEFAULT_FROM_EMAIL,
subscription.email,
"subscriptions/subscription_email.txt",
{"subscription": subscription},
)
return HttpResponseRedirect(r("subscriptions:detail", subscription.pk))
示例10: create
# 需要导入模块: from eventex.subscriptions.forms import SubscriptionForm [as 别名]
# 或者: from eventex.subscriptions.forms.SubscriptionForm import save [as 别名]
def create(request):
form = SubscriptionForm(request.POST)
if not form.is_valid():
return render(request, 'subscriptions/subscription_form.html', {'form': form})
# Usando Model.Form - Quando o formulário está muito alinhado com o model
subscription = form.save()
# Usando form -> subscription = Subscription.objects.create(**form.cleaned_data)
# Send email
_send_email('subscriptions/subscription_email.txt', {'subscription': subscription},
'Confirmação de inscrição', settings.DEFAULT_FROM_EMAIL, subscription.email)
# Success feedback
# messages.success(request, 'Inscrição realizada com sucesso!')
return HttpResponseRedirect(r('subscriptions:detail', subscription.pk))