title: FactoryBoy assign attribute to attribute of SubFactory
body: <p>In defining a ModelFactory in FactoryBoy, I need to access an attribute of another model created by SubFactory and assign it to this ModelFactory's attribute.</p>
  
  <p>This is what I want to do:</p>
  
  <pre><code>import factory
  class MyModelFactory(factory.DjangoModelFactory):
      FACTORY_FOR = MyModel
  
      created_by = factory.SubFactory(AdminUserFactory)**.id**
  </code></pre>
  
  <p>Obviously that doesn't work because there is no AdminUser object to access the id in the MyModelFactory class definition.</p>
  
  <p>This is what I have done, but it is ugly:</p>
  
  <pre><code>import factory
  class MyModelFactory(factory.DjangoModelFactory):
      FACTORY_FOR = MyModel
  
      dummy_created_by = factory.SubFactory(AdminUserFactory)
      created_by = factory.LazyAttribute(lambda o: o.dummy_created_by.id)
  
      @classmethod
      def _create(cls, target_class, *args, **kwargs):
          del kwargs['dummy_created_by']
          return super(MyModelFactory, cls)._created(
              target_class, *args, **kwargs)
  </code></pre>
  
  <p>I was trying to read through the <a href="https://factoryboy.readthedocs.org/en/factory_boy-1.2.0/internals.html" rel="noreferrer">Factory_Boy docs</a> but didn't see a class or function that would allow me to lazily access the attribute. Does Anyone have any suggestions?</p>