vandersonmota/model_mommy — pull request #136 by hackoder (2013-10-31 09:55:22+00:00)
Title: Parent objects are created twice - creates multiple problems

When using [model inheritance](https://github.com/hackoder/model_mommy/blob/master/test/generic/models.py#L68), it seems like parent objects are created twice since model_mommy iterates over all fields.

1. When creating the parent_ptr field, so for e.g. the dog_ptr field on the GuardDog model. This creates a Dog instance.
2. When creating an instance of the GuardDog model after it has finished iterating over all fields.

This seems to work in simple cases where django looks at the parent_ptr field and assigns it as being the parent and not creating a new parent instance. It fails in multiple scenarios.

1. When there is a foreign key defined on the parent. [The foreign key is created twice, once for the child and once for the parent](https://github.com/hackoder/model_mommy/commit/403195006e51f846265963dd84abd011a5f03905#diff-d1422623444a23c1e072f40dbdb05afbR162)
2. When there is a datetime field on the parent with auto_now_add=True. [The parent instance (Dog) is created correctly, while the child (GuardDog) instance fails](https://github.com/hackoder/model_mommy/commit/883e6bd2974859cbc7879e868e22249deb25ae54)
3. When giving a value to a [field on an object related through a foreign key on the parent](https://github.com/hackoder/model_mommy/commit/79d85e88b556450310e122786da7b31bcdca74ec). The basic issue is the same as 1. It creates two person objects, one of which has the correct value and the other doesn't.

The basic underlying problem seems to be that there is no need to iterate over the parent_ptr field and create an instance of the parent separately from the child. My proposed fix is to skip this field. Solves all 3 issues with no other failing tests.