Django cells auto populate fields based on time

I am trying to use fixtures to auto-populate fields for a field Category

. This is how I defined it:

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)

      

I ran into the following error:

Fixture installation issue '/Users/varunj/Projects/Backend/Newsybackend/api/fixtures/admin_categories.yaml': Failed to load api.Category (pk = 1): (1048, "Column" created_on cannot be null ")

Shouldn't the fixture match the subclass fields as they say, given that they're automatic anyway?

+3


source to share





All Articles