0da968b5d4aae9fc6d9b1cd11be9114c10b6fbc1
1 def find_or_create(model
, **kwargs
):
2 instance
= model
.get_by(**kwargs
)
4 instance
= model(**kwargs
)
7 def update_or_create(model
, get_by
, update_with
):
8 instance
= model
.get_by(**get_by
)
11 for key
,value
in update_with
.items():
12 setattr(instance
, key
, value
)
17 both
.update(update_with
)
18 instance
= model(**both
)