Weird problem in Django with forms :
I have a Form.class defined like this ...
class MeetingForm(forms.Form):
owner = forms.ModelChoiceField(
queryset=Profile.objects.all(),
widget=forms.HiddenInput() )
date = forms.DateTimeField()
name = forms.CharField(max_length=30)
etc.
And I create new instances by calling a function like this ...
def newMeetingForm(request,profile) :
mf = MeetingForm( {
'date' : date.today(),
} )
return mf
Which works as expected. Except, the "owner"-field of the meeting is blank. What I think I should do is pre-fill the owner field in the newMeetingForm like this :
def newMeetingForm(request,profile) :
mf = MeetingForm( {
'date' : date.today(),
'owner' : profile,
} )
return mf
where the argument "profile" is a Profile object.
When I run this, however, the form doesn't render.
I'm using this in the template :
{{ form.as_p }}
But with that extra 'owner' line in newMeetingForm it literally seems to come out as an empty string. I assume that somehow it's failing silently, perhaps as the ModelChoiceField tries to render the owner value that I prefilled it with. But the values look OK. So what else should I be looking for?