Set a kind name independently of the model name (App Engine datastore)

心已入冬 提交于 2019-12-01 09:00:36

Just override the kind() method of your class:

class MyModel(db.Model):
  @classmethod
  def kind(cls):
    return 'prefix_%s' % super(MyModel, cls).kind()

You can define a custom baseclass that does this for you:

class ModuleModel(db.Model):
  @classmethod
  def kind(cls):
    return '%s_%s' % (cls.__module__, super(ModuleModel, cls).kind())

Any class that extends ModuleModel will have the name of the module it's defined in prefixed to the kind name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!