title: Django: Custom Metaclass Inheriting From And Extending `ModelBase`
body: <p>I am trying to do some metaclass hocus-pocus. I want my own Metaclass
  to inherit from <code>ModelBase</code> and then I want to add additional logic by
  extending its <code>__new__</code> method. However I think there is something
  strange happening with the MRO/inheritance order in the way I'm using it.</p>
  
  <p>Here is the basic situation:</p>
  
  <pre><code>from django.db.models import Model, ModelBase
  
  
  class CustomMetaclass(ModelBase):
      def __new__(cls, name, bases, attrs):
          # As I am trying to extend `ModelBase`, I was expecting this
          # call to `super` to give me the return value from here:
  
          # https://github.com/django/django/blob/master/django/db/models/base.py#L300
  
          # And that I would be able to access everyhing in `_meta` with
          # `clsobj._meta`. But actually this object is
          # `MyAbstractModel` and has no `_meta` property so I'm pretty
          # sure `__new__` isn't being called on `ModelBase` at all at
          # this point.
          clsobj = super().__new__(cls, name, bases, attrs)
  
          # Now, I want to have access to the `_meta` property setup by
          # `ModelBase` so I can dispatch on the data in there. For
          # example, let's do something with the field definitions.
          for field in clsobj._meta.get_fields():
              do_stuff_with_fields()
  
          return clsobj
  
  
  class MyAbstractModel(metaclass=CustomMetaclass):
      """This model is abstract because I only want the custom metaclass
      logic to apply to those models of my choosing and I don't want to
      be able to instantiate it directly. See the class definitions below.
      """
      class Meta:
          abstract = True
  
  class MyModel(Model):
      """Regular model, will be derived from metaclass `ModelBase` as usual.
      """
      pass
  
  class MyCustomisedModel(MyAbstractModel):
      """This model should enjoy the logic defined by our extended `__new__` method.
      """
      pass
  </code></pre>
  
  <p>Any ideas why <code>__new__</code> on <code>ModelBase</code> isn't being called by
  <code>CustomMetaClass</code>? How can I correctly extend <code>ModelBase</code> in this way? I'm pretty sure metaclass inheritance is possible
  but seems like I'm missing something...</p>