vendredi 13 mars 2015

Create a mix of string and digit with Factory Boy in django

I want to create a mix of string and digits like this: "XL1A" or "PP25" for one field in my database.How can I do that? I'm using only uppercase letter for now.



class CardFactory(DjangoModelFactory):
class Meta:
model = Card
serial_number = FuzzyText(length=4, chars=string.ascii_uppercase)


Also, is there anyway to create random pattern rules for FuzzX in Factory Boy such as random IP addresses?





Aucun commentaire:

Enregistrer un commentaire