On Nov 4, 2008, at 8:14 AM, Robocop wrote:

>
> I'm working with some rather long forms, and i've processed them in a
> pretty basic way.  I read in the post data for every field, then just
> create a new table entry using the form data.
>
> Something like:
> if request.method == 'POST':
>  if form.is_valid():
>    var_a = form.cleaned_data['var_a']
>    var_b = form.cleaned_data['var_b']
>    ....
>   var_z = form.cleaned_data['var_z']
>   new_model = Model( var_a = var_a, var_b = var_b, ... ,var_z =var_z)
>   new_model.save()
>
> Now that my forms are getting pretty long, i'm wondering if there is a
> faster way to do this.  Does anyone know of any tricks or shortcuts to
> just push a one to one mapping of my modelform to my model into a new
> table in my database?  As always, help is greatly appreciated.

If you're using a real modelform, just call save() on it:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

>
> >


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to