views:

47

answers:

1

You can create a new model in App Engine using a dictionary:

my_model = MyModel.get_or_insert(keyname, **kwargs)

Is there a way to update a model using a dictionary instead of doing the following?

my_model.firstprop = 'first'
my_model.secondprop = 'second'
+3  A: 

There's no built in method to do this, but writing your own is straightforward:

def update_model(model, values):
  for k, v in values.iteritems():
    setattr(model, k, v)
Nick Johnson