Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda