本文整理汇总了Python中models.Contact.get_absolute_url方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.get_absolute_url方法的具体用法?Python Contact.get_absolute_url怎么用?Python Contact.get_absolute_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.get_absolute_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_invitation
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import get_absolute_url [as 别名]
def send_invitation(invitation):
"""
"""
try:
user = User.objects.get(email=invitation.email)
message = "{0} added you to his contacts".format(
invitation.sender.username)
contact = Contact(owner=invitation.sender, user=user)
contact.save()
invitation.delete()
return HttpResponseRedirect(contact.get_absolute_url())
except User.DoesNotExist:
message = """
{0} Invites you to join his contacts.
You can register on http://{1}/user/create_account/ \
if you want to accept his invitation""".format(
invitation.sender.username,
Site.objects.get_current().domain
)
send_mail('An invitation sent to you',
message,
invitation.sender,
[invitation.email],
fail_silently=False
)
return HttpResponseRedirect(invitation.get_absolute_url())