> def my_view(request):
> 
>     class MyForm(forms.Form)
>          emails = forms.ModelMultipleChoiceField(queryset=
>               MyDBModel.objects.filter(user=request.user.id)
> 
> 
> But I'd like to have form declaration out of this view na pass user's
> ID as an argument - is there any way how to supply queryset in
> runtime? I tried to assign queryset later to form's instance having no
> success.

If ModelMultipleChoiceField behaves the same as ModelChoiceField, you'll
have to explicitly set the choices on the widget, too. Here's an extract
from my code :
             self.fields[f].queryset = queryset
             # Have to force the widget to update itself (bug 4787)
             self.fields[f].widget.choices = self.fields[f].choices

http://code.djangoproject.com/ticket/4787 doesn't mention
ModelMultipleChoiceField, so if you do need to do this, you should probably
update the ticket to say so.

Chris




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