本文整理汇总了Python中newsletter.models.Subscription.name方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.name方法的具体用法?Python Subscription.name怎么用?Python Subscription.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newsletter.models.Subscription
的用法示例。
在下文中一共展示了Subscription.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: form_valid
# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import name [as 别名]
def form_valid(self, form):
newsletter = self.get_services_newsletter()
email = form.cleaned_data['email']
try:
subscription = Subscription.objects.get(email_field=email, newsletter=newsletter)
except Subscription.DoesNotExist:
subscription = Subscription()
subscription.email = form.cleaned_data['email']
subscription.name = form.cleaned_data['name']
subscription.newsletter = self.get_services_newsletter()
subscription.save()
subscription.send_activation_email(action='subscribe')
messages.success(self.request, u'Вы подписались на уведомления о новых акциях стоматологического центра "Рябина"!')
else:
if subscription.subscribed:
messages.success(self.request, u'Вы уже подписаны на уведомления о новых акциях стоматологического центра "Рябина"!')
else:
subscription.send_activation_email(action='subscribe')
messages.success(self.request, u'Мы выслали вам письмо активации на уведомления о новых акциях стоматологического центра "Рябина"!')
return HttpResponseRedirect(self.get_success_url())