This repository has been archived by the owner on Oct 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cc0efe
commit 095bf5c
Showing
8 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,12 @@ def validate_ipv6_address(v): | |
|
||
|
||
#TODO: improve related models handling | ||
foreign_key_required = [lambda field: ('model', field.related.parent_model)] | ||
def _fk_model(field): | ||
try: | ||
return ('model', field.related.parent_model) | ||
except AttributeError: | ||
return ('model', field.related_model) | ||
foreign_key_required = [_fk_model] | ||
|
||
MAX_MANY_QUANTITY = 5 | ||
|
||
|
@@ -259,8 +264,8 @@ def make(self, **attrs): | |
def prepare(self, **attrs): | ||
'''Creates, but does not persist, an instance of the model | ||
associated with Mommy instance.''' | ||
self.type_mapping[ForeignKey] = prepare | ||
self.type_mapping[OneToOneField] = prepare | ||
self.type_mapping[ForeignKey] = make | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vandersonmota
Author
Collaborator
|
||
self.type_mapping[OneToOneField] = make | ||
return self._make(commit=False, **attrs) | ||
|
||
def get_fields(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Django<1.8 | ||
Django<1.9 | ||
six |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This caused some breakages on our existing unit tests.
As this is a method that claims not to persist, it seems wrong to me that it would go ahead and persist an instance of another model.
Could this be reverted to use
prepare
by default, but an argument could be specific in order to switch it over tomake
?