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
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
--~--~
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
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
--~--~-~--~~~---~
4 matches
Mail list logo