本文整理汇总了Python中models.Contact.note方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.note方法的具体用法?Python Contact.note怎么用?Python Contact.note使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.note方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: contact_add
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import note [as 别名]
def contact_add(request):
"""
Handle normal request to add a contact.
"""
if request.method != 'POST':
raise Http404
form = ContactAddForm(request.POST)
if form.is_valid():
contact_email = form.cleaned_data['contact_email']
contact = Contact()
contact.user_email = form.cleaned_data['user_email']
contact.contact_email = contact_email
contact.contact_name = form.cleaned_data['contact_name']
contact.note = form.cleaned_data['note']
contact.save()
messages.success(request, _(u"Successfully adding %s to contacts.") % contact_email)
else:
messages.error(request, _('Failed to add an contact.'))
referer = request.META.get('HTTP_REFERER', None)
if not referer:
referer = SITE_ROOT
return HttpResponseRedirect(referer)
示例2: contact_add_post
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import note [as 别名]
def contact_add_post(request):
"""
Handle ajax post to add a contact.
"""
result = {}
content_type = 'application/json; charset=utf-8'
form = ContactAddForm(request.POST)
if form.is_valid():
contact_email = form.cleaned_data['contact_email']
contact = Contact()
contact.user_email = form.cleaned_data['user_email']
contact.contact_email = contact_email
contact.contact_name = form.cleaned_data['contact_name']
contact.note = form.cleaned_data['note']
contact.save()
result['success'] = True
messages.success(request, _(u"Successfully adding %s to contacts.") % contact_email)
return HttpResponse(json.dumps(result), content_type=content_type)
else:
return HttpResponseBadRequest(json.dumps(form.errors),
content_type=content_type)