On Sat, Aug 10, 2013 at 9:00 PM, Satinderpal Singh
<[email protected]> wrote:
>
> I think in the your views you are trying to save it under the formsets, try
> to save the formsets under the form to save all the required rows.
>
What should be changed?
This is my code :
def add_result(request):
class RequiredFormSet(BaseFormSet):
def __init__(self, *args, **kwargs):
super(RequiredFormSet, self).__init__(*args, **kwargs)
for form in self.forms:
form.empty_permitted = False
clas = Class.objects.get(id=request.GET['class'])
test = Tests.objects.get(id=request.GET['test'])
student = Student.objects.filter(std=clas.id)
#for students in student:
# student_id = Student.objects.get(id=students.id)
if test.id == 3 or test.id == 6:
pass
else :
FAtestFormSet = formset_factory(FAtestForm, max_num=30,
formset=RequiredFormSet)
if request.method == 'POST':
FAtestform_formset = FAtestFormSet(request.POST,
request.FILES)
if FAtestform_formset.is_valid() :
for form in FAtestform_formset.forms:
marks = form.save(commit=False)
marks.test = test
marks.save()
return
render_to_response('report/marks_filled.html',
{'student':student},
context_instance=RequestContext(request))
else:
FAtestform_formset = FAtestFormSet()
temp = {'FAtestform_formset': FAtestform_formset,
'student':student,
'test':test }
return render_to_response('report/add_marks.html', temp,
context_instance = RequestContext(request))
--
Sandeep Kaur
E-Mail: [email protected]
Blog: sandymadaan.wordpress.com
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.