@canen
An example is if your forms are dealing with two or more models
wherein form_for_model is for one model only.

@nathan
I am also new to python, where can I learn more about **kwargs?

Cheers,
james


On Jul 21, 12:46 am, canen <[EMAIL PROTECTED]> wrote:
> I may be mistaken but isn't this what form_for_model is for?
>
> On Jul 20, 11:23 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
>
> > Python also allows you to use ** to unpack a dict into a set of
> > kwargs:
>
> > b = Book(**bf.cleaned_data)
>
> > On Jul 20, 4:28 am, LaundroMat <[EMAIL PROTECTED]> wrote:
>
> > > On 20 jul, 10:53, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > > hi,
>
> > > > is there a short cut for assigning input data to model's data
> > > > attribute?
>
> > > > if Book is a model then
>
> > > > b = Book(request.POST)
> > > > b.save()
>
> > > > the assignment will be done on all the match key of  the request.POST
> > > > QueryDict and data attribute of the Book Model.
>
> > > > or
>
> > > > if BookForm is a newform then
>
> > > > bf = BookForm()
> > > > if bf.is_valid():
> > > >     b = Book(bf.cleaned_data)
>
> > > > thanks
> > > > james
>
> > > You could run through the request.POST's keys and assign them to the
> > > Model's attributes:
> > > b = Book()
> > > for key in request.POST.keys():
> > > ---b.__setattribute__(key, request.POST[key])
> > > b.save()


--~--~---------~--~----~------------~-------~--~----~
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