I've been trying in vain to establish a RelatedListField relationship between two models, but can't seem to work out how to allow users to select the related entities from a Form instance. Unfortunately, every approach I've tried has resulted in an empty list or an exception which says, "'Foo' object is not iterable".
So, given the following relationship, how should I create/populate the MultipleChoiceField in my Form instance? (I'll eventually need to filter the available options, but will revisit once I have the baseline version working.)
class Foo(models.Model):
name = models.CharField(
max_length=70,
unique=True
)
class Bar(models.Model):
foos = fields.RelatedListField('Foo')