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


Python AskForm.user方法代码示例

本文整理汇总了Python中qa.forms.AskForm.user方法的典型用法代码示例。如果您正苦于以下问题:Python AskForm.user方法的具体用法?Python AskForm.user怎么用?Python AskForm.user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qa.forms.AskForm的用法示例。


在下文中一共展示了AskForm.user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ask

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import user [as 别名]
def ask(request):
    if request.method == 'POST':
        question = AskForm(request.POST)
        if question.is_valid():
            question.user = request.user
            question = question.save()
            return HttpResponseRedirect(question.get_url())		
    else:
        question = AskForm()
            
    return render(request, 'ask.html', {
            'question': question,
        })
开发者ID:meanmail,项目名称:stepic_web_technology,代码行数:15,代码来源:views.py

示例2: question_add

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import user [as 别名]
def question_add(request):
    user = request.user
    if user.is_anonymous():
        return HttpResponseRedirect(reverse('login'))

    if request.method == 'POST':
        form = AskForm(request.POST)
        form.user = user
        if form.is_valid():
            question = form.save()

            return HttpResponseRedirect(reverse('question_details', kwargs={'question_id': question.id}))
    else:
        form = AskForm()

    return render(request, 'qa/question_add.html', {
        "form": form
    })
开发者ID:namax,项目名称:stepic_web_project,代码行数:20,代码来源:views.py

示例3: question_add

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import user [as 别名]
def question_add(request):
	user = request.user
	#if not user.is_authenticated():
	#	return HttpResponseRedirect('/')
	if request.method == "POST":# and user is not None and user.is_active:
		form = AskForm(request.POST)
		form.user=request.user
		#text = request.POST['text']
		#title = request.POST['title']
		#form = AskForm(user, text=text, title=title)
		if form.is_valid():
			question = form.save()
			#return HttpResponseRedirect("/question/%s/" %question.id)
			return HttpResponseRedirect("/question/"+str(question.id)+"/") 
			#return redirect('question_details', question.id)
			#return redirect("/question/%s/" %question.id)
	else:
		form = AskForm()
	return render(request, 'qa/question_add.html', {
		'form': form
	})
开发者ID:MelroiN,项目名称:web_test,代码行数:23,代码来源:views.py


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