📜  创建基础模型 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:54.214000             🧑  作者: Mango

代码示例1
class BaseModel(models.Model):  # base class should subclass 'django.db.models.Model'

    creation_date = models.DateTimeField(..) # define the common field1
    validity_start_date = models.DateTimeField(..) # define the common field2
    validity_end_date = models.DateTimeField(..) # define the common field3

    class Meta:
        abstract=True # Set this model as Abstract