本文整理汇总了Python中models.Answer.session_key方法的典型用法代码示例。如果您正苦于以下问题:Python Answer.session_key方法的具体用法?Python Answer.session_key怎么用?Python Answer.session_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Answer
的用法示例。
在下文中一共展示了Answer.session_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _saveable_answer
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import session_key [as 别名]
def _saveable_answer(self, ans=None):
if ans is None:
ans = Answer()
ans.question = self.question
ans.session_key = self.session_key
if self.user.is_authenticated():
ans.user = self.user
else:
ans.user = None
ans.interview_uuid = self.interview_uuid
return ans
示例2: save
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import session_key [as 别名]
def save(self, commit=True):
if not self.cleaned_data['answer']:
if self.fields['answer'].required:
raise ValidationError, _('This field is required.')
return
ans_list = []
for text in self.cleaned_data['answer']:
ans = Answer()
ans.question = self.question
ans.session_key = self.session_key
ans.text = text
if commit: ans.save()
ans_list.append(ans)
return ans_list
示例3: save
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import session_key [as 别名]
def save(self, commit=True):
if not self.cleaned_data["answer"]:
if self.fields["answer"].required:
raise ValidationError, _("This field is required.")
return
ans_list = []
for text in self.cleaned_data["answer"]:
ans = Answer()
ans.question = self.question
ans.session_key = self.session_key
if self.user.is_authenticated():
ans.user = self.user
else:
ans.user = None
ans.interview_uuid = self.interview_uuid
ans.text = text
if commit:
ans.save()
ans_list.append(ans)
return ans_list