I want to define a base Document to define some public filed and method. But I found the child Document can't define it's custom name when inheritance. such as:
from mongoengine import *
class BaseInfo(Document):
account = StringField()
insert_time = IntField()
update_time = IntField()
meta = {'allow_inheritance': True}
class SonItem(Document, BaseItem):
age = IntField()
meta = {'collection': 'son_item'}
meta = {'allow_inheritance': True}
class GrandItem(Document, BaseItem):
age = IntField()
meta = {'collection': 'grand_item'}
This will comes the error:
SyntaxWarning: Trying to set a collection on a subclass (SonItem)