Thursday, November 1, 2012

Re: Problem with formset




On Fri, Nov 2, 2012 at 1:41 AM, Lachlan Musicman <datakid@gmail.com> wrote:
On Thu, Nov 1, 2012 at 6:32 PM, Satinderpal Singh <satinder.goraya91@gmail.com> wrote:
On Thu, Nov 1, 2012 at 1:25 AM, Lachlan Musicman <datakid@gmail.com> wrote:
On Thu, Nov 1, 2012 at 7:30 AM, Satinderpal Singh
<satinder.goraya91@gmail.com> wrote:
> I use formset in my views.py file for the forms. It saves the entries from
> the form to the database but the problem is that it shows all the previous
> forms along with the new form for the new entry. The code for my views file
> is given below:
>
> def chemical_analysis(request):
> ChemicalFormSet = modelformset_factory(chem_analysis)
> if request.method=='POST':
>                 formset = ChemicalFormSet(request.POST, request.FILES)
>                 if formset.is_valid():
> cd = formset.cleaned_data
> formset.save()

Should that be cd.save()? Where else is cd used?
No other cd is used in this view, and i did not get your above logic, cd.save() 


I think you are saying you don't understand my response? I'm asking if the problem is fixed by replacing formset.save() - with cd.save(), since you have cd = formset.cleaned_data but no other instances of cd, making it kinda useless?
I tried this way, but it do not solve the problem.  

should here be a cd = ObjectName() in there?
If that is the case, how cd can save the data. But the problem is not with saving the entries but to clear the previous form entries. 

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment