Bound/unbound shouldn't affect things. See the docs on the subject of ModelMultipleChoiceFields:
http://docs.djangoproject.com/en/1.2/ref/forms/fields/#modelmultiplechoicefield and have your queryset parameter point to a callable that performs whatever filtering logic you require. On Jun 4, 8:50 am, Massimiliano della Rovere <massimiliano.dellarov...@gmail.com> wrote: > Thanks Scott, > I have one doubt though: I need a bound form to properly set the queryset. > Using your method I'd use an unbound form, am I wrong? > > > > On Fri, Jun 4, 2010 at 14:33, Scott Gould <zinck...@gmail.com> wrote: > > Create a ModelForm for your model (A), set the queryset to what you > > want on the appropriate field (n), and then register that ModelForm > > for admin use in your admins.py. > > > Regards > > Scott > > > On Jun 4, 6:14 am, Massimiliano della Rovere > > <massimiliano.dellarov...@gmail.com> wrote: > >> When displayed in the Admin interfaces, I'd like to filter the values > >> of n, so that instances of N already linked to other instances of A > >> sharing the same instance of o are not shown: > >> so when you edit an instance of A (let's call it "a"), you see only > >> the instances of n in use by a and the unsed ones (in the context of > >> o). > > >> The problem is that I am not allowd to write self.choices_for_n() > > >> Does anybody know any solution for this? > > >> class A(models.Model): > >> o = models.ForeignKey(O) > >> p = models.ManyToManyField(P) > >> n = models.ManyToManyField(N, > >> limit_choices_to=self.choices_for_n()) > > >> def choices_for_n(self): > >> unwanted = [] > >> for z in self.o.z_set.all(): > >> if z.id == self.id: > >> continue > >> unwanted += [z.id for z in z.n] > >> for n in N.objects.exclude(id__in=unwanted): > >> yield n.id > > > -- > > 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 > > athttp://groups.google.com/group/django-users?hl=en. -- 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.