Ok hopefully this will be the last stupid question I ask for a long
time... been struggling with this for several hours:

I've got a ModelMultipleChoiceField in a form as such

class ApplicationCriteraForm(forms.Form):
  pay_hourly = forms.CharField()
  pay_yearly = forms.CharField()
  locations = 
forms.ModelMultipleChoiceField(Location.objects.all(),widget=forms.CheckboxSelectMultiple())
  transportation_method =
forms.ModelMultipleChoiceField(TransportMethod.objects.all(),
widget=forms.CheckboxSelectMultiple())
  driving_violations = forms.ChoiceField(BOOLEAN_CHOICE,
widget=forms.CheckboxSelectMultiple())

Now when I use this form I may have preset data for it, as in the form
is being used to update info instead of create it so I do something
like this:

criteria_form = ApplicationCriteraForm(initial={
    'pay_hourly' : application.pay_hourly,
    'pay_yearly' : application.pay_yearly,
    'locations ' : application.locations,
    'transportation_method' : application.transportation_method,
    'driving_violations' : application.driving_violations
  })

None of the multiple choice fields pre-popluate with data.  I've tried
a number of different methods as it looks like what the various
SelectMultiple widgets expect is a list of the id's but none of the
following work:


'locations ' : application.locations,
'locations ' : application.locations.all(),
'locations ' : [ int(location.id) for location in application.locations.all()]
'locations ' : application.locations.values()

Also it doesn't matter whether it's the CheckboxSelectMultiple or another.

Not real sure where what else to try... digging through django source
cause I'm sure I'm doing something amazingly stupid.

Vance





-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
 - Jacques Derrida

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to