[Django]-Inheriting Meta Class in Django Models

51👍

You should declare your Base class abstract in order to access its Meta class as an attribute.

class A(models.Model):
    class Meta:
        app_label='yourapp'
        abstract=True

class B(A):
    class Meta(A.Meta):
        db_table='yourtable'

Relevant documentation: https://docs.djangoproject.com/en/3.2/topics/db/models/#meta-inheritance

👤Emile

Leave a comment