本文整理汇总了Python中forms.QuestionForm.cleaned_data['explanation']方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionForm.cleaned_data['explanation']方法的具体用法?Python QuestionForm.cleaned_data['explanation']怎么用?Python QuestionForm.cleaned_data['explanation']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.QuestionForm
的用法示例。
在下文中一共展示了QuestionForm.cleaned_data['explanation']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createQuestion
# 需要导入模块: from forms import QuestionForm [as 别名]
# 或者: from forms.QuestionForm import cleaned_data['explanation'] [as 别名]
def createQuestion(request, project_id):
p = get_object_or_404(Project, pk = project_id, owner = request.user)
if request.method == 'POST': # If the form has been submitted...
question = Question(relatedProject = p) # set the relatedProject field which is not included in the form
#form = QuestionForm(sanitized, instance = question) # A form bound to the POST data
form = QuestionForm(request.POST, instance = question) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
#title = form.cleaned_data['title']
form.cleaned_data['explanation'] = sanitizeHtml(form.cleaned_data['explanation'])
#relatedProject = form.cleaned_data['relatedProject']
#tags = form.cleaned_data['tags']
#new_question =
new_question = form.save()
qid = str(new_question.pk)
return HttpResponseRedirect('/flow/' + project_id + '/' + qid + '/' + '#' + qid) # Redirect after POST
else:
form = QuestionForm() # An unbound form
variables = RequestContext(request, { 'form': form, 'url_project' : p })
return render_to_response('flow/createquestion.html', variables)