How to make FactoryBoy's ImageField generate image before save() is called?
I've found a workaround:
from django.core.files.base import ContentFileclass ImageFactory(factory.django.DjangoModelFactory): class Meta: model = Image image = factory.LazyAttribute( lambda _: ContentFile( factory.django.ImageField()._make_data( {'width': 1024, 'height': 768} ), 'example.jpg' ) )