[Answered ]-Strange errors using factory_boy and DjangoModelFactory

1👍

So after some debugging, I figured out that there was a save() method override that did something somewhat strange

Some users will call the save() method twice, someone did this in our codebase, the code looks like so :

def save(self, *args, **kwargs):
    if not self.email:
        self.email = None
    # validate_password(self._password)
    super().save(*args, **kwargs)

    if not self.batch_group:
        self.batch_group = self.id % 432

    super().save(*args, **kwargs)

for some reason this causes errors with factory_boy

Leave a comment