i would like to define a factory class for a User django model like this :
class User(models.Model):
name = models.CharField(null=True, blank=True)
created_date = models.DateField(null=True, blank=True)
but for all fields, i would like to have a fake value from Faker or None because the model allow null. Ideally, the choice between fake value and None is made by probability for example 90% for fake value and 10% for none. i guess a factory like this
class UserFactory(factory.django.DjangoModelFactory):
name = factory.Faker("random_choice", elements=[factory.Faker("name"), None], p=[0.90, 0.10]))
created_date = factory.Faker("random_choice", elements=[factory.Faker("date"), None], p=[0.90, 0.10]))