The documentation made this seem trivial but I must be missing something. I have an order form with a many to many field to ArchivedFiles. I want to just show file choices that start with the order number given to the form at instantiation. I almost works.
class OrderForm(ModelForm): def __init__(self,*args,**kw): self.ordernumber = '%06d'%kw.pop('ordernumber',0) print 'myquery',self.myquery() self.__class__.associated_files=ModelMultipleChoiceField(queryset=self.myquery(),required=False) ModelForm.__init__(self,*args,**kw) def myquery(self): A=ArchivedFile.objects.filter(name__startswith=str(self.ordernumber)) return A but now if i run it: >>> F=OrderForm(ordernumber=000002) myquery [<ArchivedFile: 2010/08/000002test.py>] >>> m=F.fields['associated_files'] >>> m._queryset [<ArchivedFile: 2010/08/test0.txt>, <ArchivedFile: 2010/08/test1.txt>, <ArchivedFile: 2010/08/test2.txt>, <ArchivedFile: 2010/08/test3.txt>, <ArchivedFile: 2010/08/000002test.py>] I give a queryset that clearly has one item but the formfield ends up with all 5 of the files. what goes wrong with the queryset keyword system? -- 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.