Broken subclass functionality with "objects"
Closed this issue · 4 comments
After commit: 7b50566
By my recommendation we hard-coded "objects" attribute as Django documentation appeared to make this seem necessary.
Example:
class Exhibitored(TypedModel, PublishModel):
Where PublishModel is overriding the objects manager and TypedModel due to our code now overwrites that same manager.
It appears we could have got around this by modifying _default manager on cls.class. Will submit a pull request with the suggested fix.
I could be wrong, but I don't think there's a sane way to fix this in third-party apps when using Django 1.10+. If you need to override objects
then you need to make a new manager which is a subclass of TypedModelManager
:
class ExhibitManager(PublishManager, TypedModelManager):
pass
class Exhibitored(TypedModel, PublishModel):
...
objects = ExhibitManager()
Changing cls.__class__._default_manager
doesn't sound right (I think that's ModelBase._default_manager
- changing it would affect every model class in the project)
Should be good now in pull request #33, but it could use some peer review. I have tested myself and it appears to work as expected inheriting any additional "objects" if they exist. TravisCI is happy.
As of #37, custom managers for TypedModel
subclasses must explicitly subclass TypedModelManager
(as in @craigds's comment above). So I don't think any further action is needed on this issue. Close?
yep. thanks