Never mind, alraidy fixed it.
Was not aware that the "initial" wanted a dictionary, not a resultset

now doing:
dict = {}
    for arr in request.arrondissement.all():
        dict[arr.id] = True

    form = SearchForm({'arrondissement': dict,})




On 1 apr, 16:14, Sander <sander.garret...@gmail.com> wrote:
> Hi guys,
>
> This might be a very simple question but it's really driving me crazy
> for not working.
>
> I'm trying to set the initial selected values of a
> ModelMultipleChoiceField like this:
>
> class MyForm(forms.Form):
>     arrondissement =
> forms.ModelMultipleChoiceField(queryset=Arrondissement.objects.all(),
> widget=forms.CheckboxSelectMultiple, required=False, help_text='')
>
>     def __init__(self, *args, **kwargs):
>         super(MyForm, self) .__init__(*args, **kwargs)
>         self.fields['arrondissement'].initial =
> Arrondissement.objects.filter(type='A')
>
> What am I doing wrong?
> I'm not getting any errors, just no selected values
>
> thanks

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