Created
September 29, 2016 16:35
-
-
Save tmehlinger/84fadb0fe72fd1e2abe25da27d1f9d73 to your computer and use it in GitHub Desktop.
ugh django orm
This file contains hidden or 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
@pytest.fixture | |
def GroupFixture(): | |
def wrapper(name='Test Group'): | |
return Group(name=name) | |
return wrapper | |
@pytest.fixture | |
def UserFixture(): | |
def wrapper(groups=None): | |
groups = groups or [] | |
u = User() | |
u.memberships = [GroupMember(user=u, group=g) for g in groups] | |
u.save() | |
return u | |
return wrapper | |
E ValueError: save() prohibited to prevent data loss due to unsaved related object 'group'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment