Skip to content

Commit

Permalink
Let __init__ of your model get access to all given properties
Browse files Browse the repository at this point in the history
In some scenario your model might define some default values
 based on properties given at creation time.
This is only possible if __init__ receives all properties at once.
  • Loading branch information
ticosax committed Jan 11, 2019
1 parent 296d244 commit 7a4996e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions flask_potion/contrib/alchemy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ def _query_get_first(self, query):

def create(self, properties, commit=True):
# noinspection properties
item = self.model()

for key, value in properties.items():
setattr(item, key, value)
item = self.model(**properties)

before_create.send(self.resource, item=item)

Expand Down

0 comments on commit 7a4996e

Please sign in to comment.