Frequently Asked Questions#
2. How can I use this with factory_boy?#
To handle tags, refer to factory_boy’s documentation on many-to-many relationships for insights and ideas.
One way to handle this is with post-generation hooks.
class ProductFactory(DjangoModelFactory):
# Rest of the stuff
@post_generation
def tags(self, create, extracted, **kwargs):
if not create:
return
if extracted:
self.tags.add(*extracted)