Код: Выделить всё
class ConfigurationSingletonFactory(DjangoModelFactory):
class Meta:
model = Configuration
django_get_or_create = ("id",)
id = 1
custom_theme = ImageField(color="blue", width=200, height=200)
class GeneralConfiguration(SingletonModel):
custom_theme = PrivateMediaImageField("Custom background", upload_to="themes", blank=True)
Код: Выделить всё
def test_config(self):
conf = GeneralConfigurationSingletonFactory(
custom_theme__name="image.png"
)
print(conf.custom_theme.width)
self.assertEqual(conf.custom_theme.width, 200)
Код: Выделить всё
ValueError: The 'custom_theme' attribute has no file associated with it.
Подробнее здесь: https://stackoverflow.com/questions/790 ... actory-boy