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 foreign key widget is not, thus the user has to make
a choice. I want the choice that I presume to be correct to be
already presented.
Surely this must be possible? BTW I have tried every variation I can
think of at the end of that line, with quotes, without quotes, and as
a request.session value (that I know is set).
Thanks for your reply.
Mike
On Jun 23, 1:08 pm, Kenneth Gonsalves <[email protected]> wrote:
> 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
> kghttp://lawgon.livejournal.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---