I am trying to load a fixture during a django test case, but m2m_changed
signal kicks in and it gives an error (the signal checks that a foreignkey is in a related state).
This answer suggests using the disable_for_loaddata
decorator, but m2m_changed
doesn't have a raw
field.
I have tried:
class DaysTests(APITestCase):
fixtures = ['initial_data.json'] # fixture is loaded before disabling m2m_changed
def setUp(self):
m2m_changed.disconnect(days_handler, sender=Foo.days.through)
def test_api(self):
# test logic.
Initial data is loaded before disabling the m2m_changed
signal.
What is the right way to disconnect/disable a m2m_changed
signal?