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
)