本文整理汇总了Python中models.Answer.author_id方法的典型用法代码示例。如果您正苦于以下问题:Python Answer.author_id方法的具体用法?Python Answer.author_id怎么用?Python Answer.author_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Answer
的用法示例。
在下文中一共展示了Answer.author_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import author_id [as 别名]
def save(self):
# getting Question by ID
print 'AnswerF save: %s (%s)' % ( self.cleaned_data, self.cleaned_data['question'])
q_id = int(self.cleaned_data['question'])
quest = Question.objects.get(id = q_id)
#ans = Answer(**self.cleaned_data)
ans = Answer(text = self.cleaned_data['text'])
ans.author_id = 1
quest.answer_set.add(ans)
quest.save()
return ans
示例2: filldb
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import author_id [as 别名]
def filldb(request, cou):
for x in range(0, int(cou)):
q = Question(title = "Question #"+str(x),
text = "Just a question with number "+str(x))
q.rating = x
q.author_id = 1
q.added_at = date(2016, 03, 1+x)
q.save()
q.added_at = date(2016, 03, 1+x)
for y in range(1, x+2):
a = Answer(text = "answer #"+str(y)+" for question #"+str(x))
a.author_id = 1
q.answer_set.add(a)
q.save()
return HttpResponse("OK")
示例3: save
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import author_id [as 别名]
def save(self):
answer = Answer(**self.cleaned_data)
answer.author_id = self._user.id
answer.save()
return answer