> mediaform = CustomMediaForm
> # get the initial queryset fo a large table
> qs=mediaform.base_fields['somefield'].queryset
>
> forms = []
>
> for  i in requested_forms:
>     form=mediaform(data, auto_id="some_generated_id")
>     # assign the queryset to the choices
>     form.base_fields['somefield'].queryset = qs
>     forms.append(form)

I think the easiest solution would be to not use modelchoicefield
here, and set the choices manually like Rajesh suggested.

choices=[(o._get_pk_val(),str(o) for o in qs]
for i in requested_forms:
    form=CustomMediaForm(data,auto_id="some_generated_id")
    form.fields['somefield'].choices = choices

Unless you're CustomMediaForm is from a generator like
form_for_instance, you'd probably be better off modifying form
specific things like choices after instantiation.  For example if you
had 10 instanaces of CustomMediaForm with choiceset A, and 10 with
choiceset B on the same page, modifying basefields would affect all 20
instances with the last choiceset assigned since basefields is shared
by all class instances.



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