

@login_required
def edit_question(request, question_id):
    context = {
        
    }
    question = Question.objects.get(pk=question_id)
    old_revision = question.get_active_revision()
    if (request.method == 'POST'):
        form = QuestionForm(request.POST, instance=question)
        if form.is_valid():
            form.save()
            question = form.save()
            if (old_revision.text != form.cleaned_data['body']):
                new_revision = QuestionRevision(question=new_revision, user=request.user, text=form.cleaned_data['body'], active=True)
                new_revision.save()
                old_revision.active = False
                old_revision.save()
            return HttpResponseRedirect(('/question/%s' % question_id))
    else:
        form = QuestionForm(instance=question, initial={
            'body': old_revision.text,
        })
    context['form'] = form
    return r2r(request, 'edit_question', context)

dataset/ETHPy150Open dropbox/questions/questions/views.py edit_question/VarMisuse@112/138 `question`->`new_revision`