Hi,
Maybe you could try this:

user_choices = [(u.id, u) for u in User.objects.filter(query)]
form['field_name'].formfield.choices = user_choices

choices expects a list of tuples in the form of (value, display), so
that it generates a select field like this:
<select name="field_name">
     <option value="value1">display1</option>
     <option value="value2">display2</option>
     ..... etc
</select>

Regards,
Jorge

On 7/1/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
> How can I limit the choices in an AddManipulator?
>
> I have a m2m relation to User, and it presents all users. I'd like to
> filter and only present a subset.
>
> I've tried setting the choices of the SelectMultipleField, but haven't
> had any luck finding the correct incantation. I've gotten as far as
> trying this after I create the form
>
> form['field_name'].formfield.choices = User.objects.filter(query)
>
> but get some error regarding unpacking a tuple. (I think this is more a
> Python gotcha than a Django one.)
>
> Any help?
> Todd
>
>
> >
>

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

Reply via email to