Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread adelaide_mike
Thank you TiNo that works if altered slightly like so: if form.is_valid(): instance = form.save(commit=False) instance.street_id= request.session['street_id'] instance.save() I have been using Django for about ten days, and it requires very d

Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread TiNo
On Fri, Jun 5, 2009 at 11:04, adelaide_mike wrote: > Exception Value: 'PropertyForm' object does not support item > assignment > There you go. You can't do: > form['street']=request.session['street_id'] You can save the form instance first, without commiting, then set the street the instance

Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread adelaide_mike
Thanks for the offer. I have altered the function as suggested: def property_data(request, property_id='0'): message = '' st = request.session['street_id'] print "At start of property_data, request.method=", request.method print "At start of property_data, st=", s

Re: Newbie - record parent ID in child data entered by ModelForm

2009-06-05 Thread Daniel Roseman
On Jun 5, 5:33 am, adelaide_mike wrote: > Another "in principle" question.  My Street model is the parent of my > Property model, many to one via foreign key. > > User selects the street and I store it in request.session. User then > gets to enter the property details in this form: > > class Prop