Hi everybody,

I'm trying to create a populated form for users to edit information
already stored in the database. Everything is working except for the
ModelChoiceField. I read that you should give the form constructor the
ID of the model you are using but that isn't working. Nor does giving
it the object, the name, or anything else I've tried.

Here is the form model:

class WorktimeForm(forms.Form):
        employee = forms.ModelChoiceField( Employee.objects.all() )
        date = forms.DateField( widget=SelectDateWidget() )
        start_time = forms.TimeField()
        end_time = forms.TimeField()


Here is the call:
data = { 'employee': Employee.objects.get( employee_pk_id =
1 ).employee_pk_id, 'date': a.start_time.date, 'start_time':
a.start_time.time, 'end_time': a.end_time.time }
form = WorktimeForm( initial=data )

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to