Django - how to determine if a model class is abstract

If the django model is made abstract, as shown below, is there a way to test the class to determine if it is abstract?

class MyModel(models.Model):
  class Meta:
    abstract = True

I would expect that I can learn MyModel.Meta.abstract, but according to the Django docs:

Django makes one adjustment for the Meta class of the abstract base class: before setting the Meta attribute, it sets abstract = False . This means that children of abstract base classes do not automatically become abstract classes.

Any ideas? Thanks!

+5
source share
2 answers

You can create an instance of MyModel and then check ._meta.abstract.

So in the code:

m = MyModel()
print m._meta.abstract
+12

, , , . Django , _meta .

, @sheats code,

from django.db.models import Model
class MyModel(Model):
  pass
print MyModel._meta.abstract

,

from django.db.models import Model
class MyModel(Model):
  class Meta(object):
    abstract = True
print MyModel._meta.abstract

, , Django Model.

from django.contrib.auth.models import User
print User._meta.abstract
+1