本文整理汇总了Python中models.Match.hash方法的典型用法代码示例。如果您正苦于以下问题:Python Match.hash方法的具体用法?Python Match.hash怎么用?Python Match.hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: match_post
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import hash [as 别名]
def match_post(request):
"""
Form posted to this url, creates the match and returns a link to send the next one to
"""
if request.method != 'POST':
return HttpResponseRedirect("http://keen.to/match")
chosen = request.POST.getlist('chosen[]')
email = request.POST.get('email')
suggested = []
for c in chosen:
if c not in options:
suggested.append(c)
new_match = Match(email_1 = email, chose_1 = chosen, views=[get_client_ip(request)], suggested = suggested)
new_match.save()
id_ = new_match.id
hasher = hashlib.sha1(str(id_))
hash_ = base64.urlsafe_b64encode(hasher.digest())[:5]
new_match.hash = hash_
new_match.save()
#Email them the number?
return render_to_response('match_post.html', {'link' : 'http://keen.to/match/' + hash_, 'hash' : hash_, 'showform' : True}, context_instance=RequestContext(request))