Friday, November 13, 2009

Re: how to save a forms.ModelForm with extra fields?

great. Thank you!

On Nov 13, 1:42 pm, Hector Garcia <hecto...@gmail.com> wrote:
> Exactly, it ignores whatever POST value not related to the model
> field. You have to use f.cleaned_data['rating'] to get the rating
> value and use it or save it wherever it has to be stored, as Andy
> McKay pointed in his comment.
>
> Hector Garcia - Web developer, musicianhttp://nomadblue.com/
>
> On Fri, Nov 13, 2009 at 11:59 AM, jul <juj...@gmail.com> wrote:
> > What happen to the rating field when doing the following?
>
> > f = AddRestaurantForm(request.POST)
> > f.save()
>
> > Does save() only use what it needs to fill the Restaurant instance and
> > doesn't use the rating value?
>
> > On Nov 13, 5:35 am, Andy Mckay <a...@clearwind.ca> wrote:
> >> On 09-11-12 2:33 PM, jul wrote:
>
> >> > I've got the Rating model and the AddRestaurantForm shown below. In
> >> > order to add a rating when submitting a new restaurant, I added an
> >> > extra field to AddRestaurantForm. Can I do that? If I can, how can I
> >> > save separately the Restaurant instance and the rating instance (I'll
> >> > get the user from the context)?
>
> >> Sure that works just fine.
>
> >> When you save the form, you'll save the restaurant instance. You can
> >> then get the rating from the forms.cleaned_data and save that however
> >> you'd like.
> >> --
> >>    Andy McKay
> >>    @clearwind
> >>    Training:http://clearwind.ca/training/
> >>    Zen:http://djangozen.com
>
> > --
>
> > 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 athttp://groups.google.com/group/django-users?hl=.

--

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=.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate