Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Django Models inherit managers? (Mine seem not to)

I have 2 models:

class A(Model):
    #Some Fields
    objects = ClassAManager()

class B(A):
    #Some B-specific fields

I would expect B.objects to give me access to an instance of ClassAManager, but this is not the case....

>>> A.objects
<app.managers.ClassAManager object at 0x103f8f290>
>>> B.objects
<django.db.models.manager.Manager object at 0x103f94790>

Why doesn't B inherit the objects attribute from A?

like image 848
Zach Avatar asked Nov 06 '22 15:11

Zach


1 Answers

Your base class will need to be an abstract base class in order for the custom manager to be inherited, as described here

like image 82
Derrick Marcey Avatar answered Nov 11 '22 03:11

Derrick Marcey