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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to