On 5/18/2009 4:01 PM, geraldcor wrote: > Hello all, > > I am working on my second Django app and it involves a very long form. > I successfully used modelForms in my last app to successfully save > form data to a database. > > With this long form, I have split it up into smaller forms (forms.Form > not ModelForms) and used the FormWizard to tie it all together. All is > well so far. However, now I have no idea how to save the form data > from form_list into my database. It is only one table so I don't have > any foreign key stuff going on. I just need to save the form data and > move on with my life :) > > I have searched the Django site and web extensively and haven't found > anything useful about saving data from regular forms or FormWizards.
Just instantiate a new Model object with the form attributes assigned to the proper model attributes, and save the object. If you happen to name your form fields the same as your model fields, then you can just use cleaned_data directly: {{{ form_data = {} for form in form_list: form_data.update(form.cleaned_data) m = Model.objects.create(**form_data) }}} -- George --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---