I have been dealing with this problem for a day and a half and I figured it was time to ask an expert.
I took the time to write it up as nicely as I could in a GitHubGist since groups does not support styling.
https://gist.github.com/dtw45/46fbbf01cf73f368ecb060f162705f22
Thanks,
Derek
Overriding the _create method was exactly what I was looking for.
This is what I wound up with.
##### Begin code excerpt #####
class StopFactory(DjangoModelFactory):
class Meta:
model = Stop
# No need to add defaults since they will just
# be overwritten by the overridden create method
@classmethod
def _create(cls, model_class, day_id, location, **kwargs):
# Override the default `create()` recipe to use create_stop
return model_class.objects.create_stop(day_id, location, kwargs)
class AdvanceFactory(DjangoModelFactory):
class Meta:
model = Advance
day = factory.Iterator(TourDay.objects.all())
tour = factory.SelfAttribute('day.tour')
stop = factory.SubFactory(StopFactory,
day_id=factory.SelfAttribute('..day.id'),
location=factory.SelfAttribute('..venue.location'))
venue = factory.Iterator(Venue.objects.all())
label = factory.SelfAttribute('venue.name')
notes = lazy_attribute(lambda o: faker.sentence())
manager_notes = lazy_attribute(lambda o: faker.sentence())
##### End code excerpt #####
Thanks, again!
-Derek