예제 #1
0
def question_add(request):
    if request.method =='POST':
        form = AskForm(request.POST)
        form._user = request.user
        if form.is_valid():
            question = form.save()
            url = question.get_url()
            return HttpResponseRedirect(url)
    else:
        form = AskForm()
        form._user = request.user
    return render(request, 'question-add.html', {
        'form': form
        })
예제 #2
0
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()
            return HttpResponseRedirect(url)
    else:
        form = AskForm()
    return render(request, 'qa/ask_form.html', {'form': form})
예제 #3
0
def add_question(request):
    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, 'add_question.html', {
        'form': form,
    })
예제 #4
0
def ask(request):
    if request.method == "POST":
        form = AskForm(request.POST)
        if form.is_valid():
            form._user = request.user
            post = form.save()
            #redirect_url = post.get_url()
            redirect_url = reverse('question_detail', args=[post.id])
            return HttpResponseRedirect(redirect_url)
    else:
        form = AskForm()
    return render(request, 'ask.html', {'form': form})
예제 #5
0
def ask(request):
    if request.method == "POST":
        form = AskForm(request.POST)
        if form.is_valid():
            form._user = request.user
            question = form.save()
            url = question.get_url()
            return HttpResponseRedirect(url)
    else:
        form = AskForm()
    return render(request, 'qa/ask.html', {
        'form': form,
    })
예제 #6
0
def ask_add(request):
    if request.method == 'POST':
	form = AskForm(request.POST)
	if form.is_valid():
	    form._user = request.user 
	    question = form.save()
	    # url = question.get_url()
	    # return HttpResponseRedirect(reverse(url))
	    return HttpResponseRedirect(reverse('question', args=[question.id]))
    else:
	form = AskForm()
	
    return render(request, 'ask_add_page.html', {'form': form})
예제 #7
0
파일: views.py 프로젝트: PHantoMby/3
def post_ask_add(request, *args):
	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('/question/'+str(post.id)+'/')
	else:
		form = AskForm()
	return render(request, 'tpl_post_ask_add.html', {
		'form': form
	})
예제 #8
0
def ask(request):
    if request.method == "POST":
        try:
            form = AskForm(request.POST)
            if form.is_valid():
                form._user = request.user
                post = form.save()
                redirect_url = post.get_absolute_url()
                print 'redirect to: ', redirect_url
                return HttpResponseRedirect(redirect_url)
        except Exception as error_message:
            print error_message
    else:
        form = AskForm()
    return render(request, 'ask.html', {'form': form})
예제 #9
0
파일: views.py 프로젝트: luchnck/teststep
def ask(request, *args, **kwargs):
	if (request.method == 'GET'):
		form = AskForm()
	else:
		form = AskForm(request.POST)
		form._user = request.user
		if (form.is_valid()):
			post = form.save()
			url = post.get_absolute_url()
			return HttpResponseRedirect(url)

	return render(request, 'ask.html',{
		"form": form,
		"_user" : request.user
		})
예제 #10
0
def ask(request):

    if request.method == 'POST':
        if request.user.is_authenticated():
            form = AskForm(request.POST)
            form._user = request.user
            if form.is_valid():
                question = form.save()
                url = question.get_url()
                return HttpResponseRedirect(url)
        else:
            return HttpResponseRedirect(default_url)
    else:
        form = AskForm()
    return render(request, 'ask_form.html',{
            'form':form,
        })
예제 #11
0
파일: views.py 프로젝트: padznich/web
def ask(request):

    if request.method == "POST":
        ask_form = AskForm(request.POST or None)
        ask_form._user = request.user
        if ask_form.is_valid():
            post = ask_form.save()
            url = post.get_url()
            print("____DEBUG: {}".format(url))
            return HttpResponseRedirect(url)
    else:
        ask_form = AskForm()

    context = {
        "ask_form": ask_form,
    }

    return render(request, 'ask.html', context)