KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
factory_boy defaults to 1 for sequences. How can I pass in a number to use as a different starting number instead? I can subclass the _setup_next_sequence() method, but how can I give it a variable to use? # File: models.py from django.db import models class Book(models.Model): title = models.CharField(max_length=100) # File: factories.py from .models import Book import factory class BookFactory(factory.Factory): FACTORY_FOR = BookModel title = factory.Sequence(lambda n: u'Title #{}'.format(n)) @classmethod def _setup_next_sequence(cls): # Instead of defaulting to starting with number 1, start with starting_seq_num. # But how do I set starting_seq_num? return starting_seq_num # File: make_data.py from factories import BookFactory # somehow set starting sequence number here? BookFactory().create() I'm using factory_boy 1.2.0 (via pip install factory_boy ) factory_boy code: https://github.com/dnerdy/factory_boy
Tags (comma-separated)
Save Edits
Cancel