当前位置: 首页>>代码示例>>Python>>正文


Python QuestionForm.cleaned_data['explanation']方法代码示例

本文整理汇总了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)
开发者ID:Seppala,项目名称:Learness,代码行数:22,代码来源:views.py


注:本文中的forms.QuestionForm.cleaned_data['explanation']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。