Hi Vance,
I suppose your code is precompiling ok but isn't it required to
explicitly state 'queryset=' before 'Location.objects.all()'?

On Sep 22, 6:15 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
> Wow this is really screwing me royal.  Doesn't work with any form of
> select, best I can tell initial doesn't work with ChoiceFields at all.
>  I've tried going into the source and logging out the value param to
> the widget and it is always just [].
>
> Am I on crack, can somebody verify, so I can file a bug report if I'm
> not. ( by default these days I just assume I'm an idiot. )
>
> Vance
>
>
>
> On Sat, Sep 20, 2008 at 8:24 PM, Vance Dubberly <[EMAIL PROTECTED]> wrote:
> > 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 aModelMultipleChoiceFieldin 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
>
> --
> 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 django-users@googlegroups.com
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