The test case below causes an empty array to be printed.
class FooTest(TestCase):
def test_foo(self):
user = G(User)
obj = G(Foo, players=[player])
print(obj.users.all())
Looking into ddf.py, I see next_instance.save() is called if the related manager has no add method, the assumption being that through must have been specified on the model.
The problem is that while the instance is saved correctly, the relationship is never created. For me this is solved by adding the following after next_instance.save()
This uses the same fixture to create an instance of the through model, establishing the relationship. I see there are currently no tests for through on ManyToManyField. Was the behaviour I'm seeing intended, or is this a bug?
I have a model
Foo
with the following fieldThe test case below causes an empty array to be printed.
Looking into
ddf.py
, I seenext_instance.save()
is called if the related manager has noadd
method, the assumption being thatthrough
must have been specified on the model.The problem is that while the instance is saved correctly, the relationship is never created. For me this is solved by adding the following after
next_instance.save()
This uses the same fixture to create an instance of the
through
model, establishing the relationship. I see there are currently no tests forthrough
onManyToManyField
. Was the behaviour I'm seeing intended, or is this a bug?