I have some models that have a common set of properties that I defined in the base class of the model from which other models inherit:
class BaseUser(ndb.Model): name = ndb.StringProperty() class DerivedUserA(BaseUser):
In some other model, I need a reference to any BaseUser
-derived model:
class MainModel(ndb.Model): user = ndb.KeyProperty(kind = BaseUser)
However, when I try to set the DerivedUserA
entity key to the DerivedUserA
property, GAE raises a BadValueError
, stating that it expects a key with Good BaseUser
, but it is assigned DerivedUserA
.
If I remove the kind
argument from my MainModel
, it will work:
class MainModel(ndb.Model): user = ndb.KeyProperty()
I could live with this, but I would rather check that I am not trying to save any object in the MainModel.user
property. Is there any way to do this?
source share