Re: Django 1.0.2 foreign key display puzzle

2009-06-23 Thread adelaide_mike
Hi Kenneth I agree that on my reading of the literature what you say is right. Here is my actual line adjusted as you suggest: form = ListingForm(initial={'date': request.session['date'], 'source_id': '2',}) In this case the date field is correctly populated with the preset date, the source foreig

Re: Django 1.0.2 foreign key display puzzle

2009-06-22 Thread Kenneth Gonsalves
On Tuesday 23 June 2009 09:14:01 adelaide_mike wrote: > form = MyModelForm(initial={'myforeignkeyfieldname': myvalue}) assuming the foreignkey value exists, then you would have to insert it's id into the field myforeignkeyfieldname_id. -- regards kg http://lawgon.livejournal.com --~--~

Re: Django 1.0.2 foreign key display puzzle

2009-06-22 Thread Rama Vadakattu
Usually Foreign keys are displayed as drop down select list where user can choose one is multiple options. Foreign keys are usually initialized with list of tuples [(internal value,display),(interavalue1,displayvalue2)..] if you want to present just prepare the list of tuples and give it to

Django 1.0.2 foreign key display puzzle

2009-06-22 Thread adelaide_mike
Having failed to get any takers to my earlier posts on this, I will keep it v. short: How do I preset a foreign key value in a Model Form? form = MyModelForm(initial={'myforeignkeyfieldname': myvalue}) does not do it. Surely this can be done? Mike --~--~-~--~~~---~