Update: factory_boy now processing it!
In the latest version of factory_boy ( 2.8.1 to this day), you can now force the sequence counter to determine the value:
Forced value for each call
To force a counter for a specific Factory instance, just pass the value to __sequence=42 :
class AccountFactory(factory.Factory): class Meta: model = Account uid = factory.Sequence(lambda n: n) name = "Test"
Then in the console:
>>> obj1 = AccountFactory(name="John Doe", __sequence=10) >>> obj1.uid
And it is also possible to reset the counter for a specific value:
>>> AccountFactory.reset_sequence(42) >>> AccountFactory().uid 42 >>> AccountFactory().uid 43
source share