Change IntegerProperty to FloatProperty of existing AppEngine DataStore

前端 未结 4 570
攒了一身酷
攒了一身酷 2021-01-06 01:31

I built an appengine application (python) which need to convert existing datastore entities in integer value (100) to float value (100.00) for currency conversion issue. How

4条回答
  •  醉梦人生
    2021-01-06 02:08

    Here is exampe for Nick Johnson's answer:

    Before:

    class Person(db.Model):
        name = db.StringProperty()
        age = db.StringProperty() #this will go to int
    

    After

    class Person(db.Expando):
        pass
    
    for person in Person.all():
        person.age = int(person.age)
        person.put()
    

    Very after:

    class Person(db.Model):
        name = db.StringProperty()
        age = db.IntegerProperty() 
    

提交回复
热议问题