本文整理汇总了Python中models.Vote.user方法的典型用法代码示例。如果您正苦于以下问题:Python Vote.user方法的具体用法?Python Vote.user怎么用?Python Vote.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Vote
的用法示例。
在下文中一共展示了Vote.user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_vote
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import user [as 别名]
def create_vote(voter, nodes):
v = Vote()
v.user = voter
v.save()
for node in nodes:
v.nodes.add(node)
v.save()
return v
示例2: create_vote
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import user [as 别名]
def create_vote(voter, nodes):
v = Vote()
v.user = voter
v.save()
for node in nodes:
v.nodes.add(node)
v.save()
for node in nodes:
node.update_favorite_for_all_parents()
return v
示例3: dvote
# 需要导入模块: from models import Vote [as 别名]
# 或者: from models.Vote import user [as 别名]
def dvote():
for i in xrange(5):
email = str(i) + '@gmail.com'
password = str(i)
try:
u = User.objects.get(username=email)
except:
u = User.objects.create_user(email, email, password)
questions = Question.objects.all()
for q in questions:
choice = random.sample(q.choice_set.all(),1)[0]
v = Vote()
v.user = u
v.question = q
v.choice = choice
v.save()
choice.votes += 1
choice.save()