У меня есть две функции в views.py:
Первая функция
def upload_blob(request, iterator, interview_id, candidate_id, question_id):
try:
interview_obj = Interview.objects.get(id=interview_id)
except ObjectDoesNotExist:
interview_obj = None
current_interview = interview_obj
if request.method == 'POST':
//do some operation
iterator = str(int(iterator) + 1)
return HttpResponseRedirect(reverse('candidate:show_question', kwargs={'iterator': iterator,'interview_id':current_interview.id,'question_id':question_id}))
else:
return render(request, 'candidate/record_answer.html')
Вторая функция
def show_question(request, iterator, interview_id, question_id):
try:
interview_obj = Interview.objects.get(id=interview_id)
except ObjectDoesNotExist:
interview_obj = None
current_interview = interview_obj
current_question_id = InterviewQuestion.objects.filter(interview_id=interview_obj)[int(iterator)].question_id.id
current_question = Question.objects.get(id=current_question_id)
**//Here if redirected from first function, I should display show_question page with incremented iterator value, but currently it's going in loop**
return HttpResponseRedirect(reverse('candidate:show_question', kwargs={'iterator': iterator,'interview_id':current_interview.id,'question_id':question_id}))
context = {'iterator':iterator, 'current_interview':current_interview,'current_question':current_question,}
return render(request, 'candidate/show_question.html', context)
В настоящее время я сталкиваюсь с проблемой цикла и повторных перенаправлений в show_question **