Prometheus
Prometheus

Reputation: 33625

Python super on Meta Class from another class

In class Test2 I want to include both the models and fields in its class Meta. Is this possible and how? This is what I have tried...

I have a mixin:

class Test1(object):
        pass
    class Meta:
        fields = ("url",)

class Test2(Test1):
        pass
    class Meta:
        super(Meta) <=== does not work
        models= test

Upvotes: 7

Views: 2867

Answers (1)

Douglas Denhartog
Douglas Denhartog

Reputation: 2054

Your answer can be found in the Django Documentation

I.E.

from django.db import models

class CommonInfo(models.Model):
    # ...
    class Meta:
        abstract = True
        ordering = ['name']

class Student(CommonInfo):
    # ...
    class Meta(CommonInfo.Meta):
        db_table = 'student_info'

Upvotes: 15

Related Questions