Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
Local field 'created_at' in class 'Attachment' clashes with field of similar name from base class 'Timestampable'

I have the following two models:

class Timestampable(models.Model):
    created_at = models.DateTimeField(null=True, default=None)
    updated_at = models.DateTimeField(null=True, default=None)

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        now = timezone.now()
        if not self.created_at:
            self.created_at = now
        self.updated_at = now

        super(Timestampable, self).save(*args, **kwargs)

class Attachment(Timestampable, models.Model):
    uuid = models.CharField(max_length=64, unique=True)
    customer = models.CharField(max_length=64)
    user = models.CharField(max_length=64)
    file = models.FileField(upload_to=upload_to)
    filename = models.CharField(max_length=255)
    mime = models.CharField(max_length=255)
    publicly_accessible = models.BooleanField(default=False)

When I try to migrate these models, I get the following error:

django.core.exceptions.FieldError: Local field 'created_at' in class 'Attachment' clashes with field of similar name from base class 'Timestampable'

I read here, here, and here that this should work when the base class is abstract. However, I marked it as abstract it still it doesn't seem to work. What else could be wrong? I am using Django 1.8.14.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Because your Timestampable model already extends from models.Model. You don't need extend Attachment model.

please use:

class Attachment(Timestampable):

instead of:

class Attachment(Timestampable, models.Model):
over 4 years ago · Santiago Trujillo Report

0

I found what was the problem. I used to have the class Timestampable not inherit from models.Model. Therefore, in one of my initial migrations, I had the line:

bases=(at_common.behaviours.Timestampable, models.Model),

I was looking for a way to remove this. Turned out that I just had to delete this line from the initial migration file.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!