john.dou.2011
john.dou.2011

Reputation: 323

how to get the data type of a property in a db.Model in appengine?

I'm storing data dynamically in the data store, so i have to know the type of a property, before storing the value. I already read the documentation for the class model and i didn't find the answer. I'll apreciate all the help

suppose i have two types of entities.

    class Custom_Suppl(db.Model):
        code=db.StringProperty(required=True)

    class Inventory(db.Model):
        code=db.FloatProperty(required=True)

I have a function that stores values in those entities

    def storeValues(databaseName,values)
        ....some code...

you see that the two entities, have the same property name, but different types of value.. So i must convert the value to the corresponding type. How do i get the type of the property? I hope this clarifies it.

Upvotes: 1

Views: 357

Answers (1)

john.dou.2011
john.dou.2011

Reputation: 323

I realized that there's a class method .properties() in the class model. It returns a dictionary of all the properties in a especific entity. Each property is a property class. See Here. It has an class attribute data_type.

Upvotes: 1

Related Questions