FactoryBoy seems to always create instances in the default database. But I have the following problem.
cpses = CanonPerson.objects.filter(persons__vpd=6, persons__country="United States").using("global")
The code points to the global database. I did not find a way to specify the database in the factory:
class CanonPersonFactory(django_factory.DjangoModelFactory): class Meta: model = CanonPerson django_get_or_create = ('name_first', 'p_id') p_id = 1 name_first = factory.Sequence(lambda n: "name_first #%s" % n) @factory.post_generation def persons(self, create, extracted, **kwargs): if not create:
source share