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


Python AskForm._user方法代码示例

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


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

示例1: ask_add

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

示例2: add_ask_page

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def add_ask_page(request):
    logger.debug("add_ask_page() !")
    if request.method == "POST":
        logger.debug("add_ask_page():  method POST")
        logger.debug("add_ask_page(): POST params - " + ", ".join(request.POST))
        logger.debug("add_ask_page(): POST[author]=" + request.POST.get('author','-'))
        form = AskForm(request.POST)
        form._user = request.user
        logger.debug("add_ask_page():  form created")
        if form.is_valid():
            logger.debug("add_ask_page():  form is valid")
            question = form.save()
            url = question.get_url()
            return HttpResponseRedirect(url)
        else:
            logger.debug("add_ask_page():  form is not valid")
            logger.debug("error:" + " ".join(form.errors))
            
    else:
        logger.debug("add_ask_page():  metod GET")
        form = AskForm()
    logger.debug("add_ask_page(): return render")
    return render(request, 'add_ask.html', {
        'form': form,
    })
开发者ID:soulondemand,项目名称:django-expirience,代码行数:27,代码来源:views.py

示例3: answer

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def answer(request):
    form = AskForm(request.POST)
    form._user = request.user
    if form.is_valid():
        question = form.save()
        url = question.get_url()
        return HttpResponseRedirect(url)
    else:
        return HttpResponseNotFound()
开发者ID:borismu,项目名称:tutorialWebDev,代码行数:11,代码来源:views.py

示例4: ask

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

示例5: ask

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def ask(request, *args, **kwargs):
    if request.method == "POST":
        form = AskForm(request.POST)
        if request.user.is_authenticated():
            form._user = request.user
        if form.is_valid():
            q = form.save()
            return HttpResponseRedirect('/question/' + str(q.pk) + '/')
    else:
        form = AskForm()
    return render(request, 'ask.html',{ 'form': form })     
开发者ID:AlexSmirnof,项目名称:web,代码行数:13,代码来源:views.py

示例6: ask

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def ask(request):
	if request.method == "POST":
		form = AskForm(request.POST)
		form._user = request.user
		if form.is_valid():
			q = form.save()
			return HttpResponseRedirect('/question/' + str(q.id) + '/')
	else:
		form = AskForm()
	return render(request, 'ask.html', {
		'form': form,
	})
开发者ID:natalizav,项目名称:stepic,代码行数:14,代码来源:views.py

示例7: question_add

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

示例8: ask

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def ask(request):
    if request.method == 'POST':
        form = AskForm(request.POST)
        if form.is_valid():
            form._user = request.user
            question = form.save()
            return HttpResponseRedirect(question.get_url())

        return HttpResponse(request.method);
    elif request.method == 'GET':
        form = AskForm()

    return render(request,"ask_form.html", { "form" : form, "user": request.user })
开发者ID:Grian,项目名称:tech2,代码行数:15,代码来源:views.py

示例9: ask

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

示例10: question_add

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

示例11: ask

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

示例12: question_ask

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def question_ask(request):
	if request.method == 'POST':
		form = AskForm(request.POST)
		if form.is_valid():
			form._user = request.user
			askquestion = form.save()
			url = reverse('question', args=[askquestion.id])
			return HttpResponseRedirect(url)
	else:
		form = AskForm()

	return render(request, 'ask.html', {
		'form': form
	})
开发者ID:StealthyFox,项目名称:web,代码行数:16,代码来源:views.py

示例13: add_question

# 需要导入模块: from qa.forms import AskForm [as 别名]
# 或者: from qa.forms.AskForm import _user [as 别名]
def add_question(request):
    if request.method == 'POST':
        form = AskForm(request.POST)
        form._user = request.user
        if form.is_valid():
            question = form.save()
            #получить url на перенаправление к станице запроса и переправить
            url = question.get_absolute_url()
            return HttpResponseRedirect(url)
    else:
        form = AskForm()
    return render(request, 'add_question.html', {
        'form': form
    })
开发者ID:arzahs,项目名称:Course-web-technology,代码行数:16,代码来源:views.py

示例14: ask

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

示例15: ask

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


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