class DataClass(object):
@abstractmethod
def aaa(self):
raise NotImplemented
@abstractmethod
def bbb(self):
raise NotImplemented
class Patient(DataClass, models.Model):
name = models.TextField(
help_text='姓名',
verbose_name=_('姓名'), max_length=20, default='', )
telecom = models.CharField(
help_text='手机号码',
verbose_name=_('手机号码'),
max_length=20, default='', )
def __str__(self):
return self.name or _('ID is %s') % self.id
def aaa(self):
return aaa(str(self.id))
def bbb(self):
return 'hello'
在类中必须重写了aaa和bbb函数,Patient类才可以被实例化,否则无法创建实例化对象