From d81919b6c8418da9bed0a78f5a7d5344f0ccbc16 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Mon, 19 Dec 2016 13:23:20 +0530 Subject: modified to check form validation --- yaksh/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yaksh/views.py b/yaksh/views.py index 98ec0fe..0d77426 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -165,17 +165,17 @@ def add_question(request, question_id=None): files = FileUpload.objects.filter(id__in=hide_files_id) for file in files: file.toggle_hide_status() + formsets = [] + for testcase in TestCase.__subclasses__(): + formset = inlineformset_factory(Question, testcase, extra=0, + fields='__all__') + formsets.append(formset(request.POST, request.FILES, instance=question)) + files = request.FILES.getlist('file_field') + uploaded_files = FileUpload.objects.filter(question_id=question.id) if qform.is_valid(): question = qform.save(commit=False) question.user = user question.save() - files = request.FILES.getlist('file_field') - uploaded_files = FileUpload.objects.filter(question_id=question.id) - formsets = [] - for testcase in TestCase.__subclasses__(): - formset = inlineformset_factory(Question, testcase, extra=0, - fields='__all__') - formsets.append(formset(request.POST, request.FILES, instance=question)) for formset in formsets: if formset.is_valid(): formset.save() -- cgit