I would like to access the Foo instance foo within my manager method baz:
foo.bar_set.baz()
baz would normally take an argument of Foo type:
BarManager(models.Manager):
def baz(self, foo=None):
if foo is None:
# assume this call originates from
# a RelatedManager and set `foo`.
# Otherwise raise an exception
# do something cool with foo
This way both the first query above and the following one works identically:
Bar.objects.baz(foo)
Bar would have a ForeignKey to Foo:
class Bar(models.Model):
foo = models.ForeignKey(Foo)
objects = BarManager()