Beispiel #1
0
def ask(request):
    if request.method == 'POST':
        form = QuestionForm(request.POST)
        if form.is_valid():
           question = Question()
           question.user = request.user
           question.title = form.cleaned_data.get('title')
           question.description = form.cleaned_data.get('description')
           question.save()
           tags = form.cleaned_data.get('tags')
           question.create_tags(tags)
           return redirect('/questions/')
        else:
            return render(request, 'questions/ask.html', {'form': form})
    else:
        form = QuestionForm()
    return render(request, 'questions/ask.html', {'form': form})
Beispiel #2
0
def unanswered(request):
    questions = Question.get_unanswered()
    return _questions(request, questions, 'unanswered')
Beispiel #3
0
def answered(request):
    questions = Question.get_answered()
    return _questions(request, questions, 'answered')