我正在尝试使用灯具自动填充Category
字段的字段。这是我定义它的方式:
class TimeStampedModel(models.Model):
""" TimeStampedModel
An abstract base class model that provides self-managed "created" and
"modified" fields.
"""
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)
class Category(TimeStampedModel):
name = models.CharField(max_length=255)
is_regional = models.BooleanField(default=False)
subtitle = models.CharField(max_length=255, null=True, default=None)
is_selected = models.BooleanField(default=False)
我遇到以下错误:
安装夹具时出现问题 ' /Users/varunj/Projects/Backend/Newsybackend/api/fixtures/admin_categories.yaml' ;: 无法加载api.Category(pk = 1):( 1048,"列' created_on'不能 为空")
由于它们是auto_now,不应该由夹具来处理子类字段吗?