Thursday, August 21, 2014

Re: Iterate forms with for loop

On Thursday, 21 August 2014 10:33:11 UTC+1, Kamal Kaur wrote:
I'm iterating multiple forms for all the instances of a table in the
template using for loop.

But only the last form is being considered and it saves the data from
last form only. I'm not getting how to differentiate these forms and
save data, from every field and form, into the database.

Here is my code:

Template: http://paste.ubuntu.com/8104842/
View: http://paste.ubuntu.com/8104734/
Forms: http://paste.ubuntu.com/8104801/
Models: http://paste.ubuntu.com/8104814/

Am I doing it wrong or missing something important?

--
Kamaljeet Kaur


You should be using formsets.
https://docs.djangoproject.com/en/1.6/topics/forms/formsets/
https://docs.djangoproject.com/en/1.6/topics/forms/modelforms/#model-formsets
--
DR. 

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b235f265-6229-4b0a-94fe-7b924473638a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment