myyang / django-pb-model

Protobuf mixin for django model
Other
112 stars 22 forks source link

Make ProtoBufMixin a proper subclass of Model #13

Closed ssaavedra closed 4 years ago

ssaavedra commented 4 years ago

Django 2.2 detects classes in the app_installed.models module.

It seems that now they are detecting classes based on whether they are inheriting django.db.base.ModelBase. Since ProtoBufMixin must be a mixin with Model, its type needs to be a (subclass of) ModelBase, which it is (since its metaclass is pb_model.Meta which is a subclass of ModelBase).

Given that ProtoBufMixin must be now a valid Django module, we are adding its class Meta with abstract=True, in order to cause minimum hassle.

This entails that now subclasses of ProtoBufMixin are already Model, and don't need to also include models.Model into the inheritance chain. It also means that there is a spurious subclass in the middle between Model and your model class, but that seems to be benign enough, and Django should not break that if they aim not to break compatibility with model inheritance in client apps.

Fix https://github.com/myyang/django-pb-model/issues/10