On Wed, Oct 17, 2012 at 7:06 AM, Satinderpal Singh <satinder.goray...@gmail.com> wrote: > I used formsets for different forms in my project, it displays the > forms to user but on submitting the form it gives the following error: > 'chem_analysisFormFormSet' object has no attribute 'save'. I don't > know how to save the formset in the views. Here is the code of my > views file of my project: > > def chemical_analysis(request): > ChemicalFormSet = formset_factory(chem_analysisForm) > if request.method=='POST': > formset = ChemicalFormSet(request.POST, request.FILES) > if formset.is_valid(): > cd = formset.cleaned_data > formset.save() > return > HttpResponseRedirect(reverse('Automation.report.views.result_chem')) > #return > render_to_response('report/chemical_analysis.html', > {'chem': chem,},context_instance=RequestContext(request)) > else: > return HttpResponse("There was an error with > your > submission. Please try again.") > > else: > formset = ChemicalFormSet() > return > render_to_response('report/report_add_row.html', {'formset': > formset}, context_instance=RequestContext(request)) >
Why would it have a save() method? Only model forms and model formsets have save() methods. Model formsets are defined using the modelformset_factory factory, not formset_factory. https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/#model-formsets Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.