I fixed my problem, but it's very much a hack. If anyone has a better solution, please post it.
My fix was a simple hack: after every instantiation of my MemoForm class, I called a method "replace_recipients" where I changed the value of form_object.base_fields['recipients'].choices. Like I said, a hack and not a pretty one, but it works. Vincent. On May 23, 9:01 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello, > > I wrote a newforms form, but I have some problems when I want to test > the class. Here's the definition: > > def _users(): > print "calling _users()" > return [(u.id, u.get_full_name()) for u in > User.objects.filter(is_active=True)] > > class MemoForm(forms.Form): > body = forms.CharField(widget=forms.Textarea, required=True) > recipients = forms.MultipleChoiceField(choices=_users(), > required=True) > > This works fine, however when I run my tests, _users() is called at > the very beginning, so the choices in recipients come from my > production database, not from the fixtures I wrote. Does anyone know > how I could fix this? > > Thank you, > > Vincent --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---