Skip to content Skip to sidebar Skip to footer

Automatically Downcast To Subclass Using Django-model-utils

I have multiple user models .. all inheriting a Base model with a custom manager models.py class BaseUser(models.Model): [...] objects = UserManager() class StaffUser(B

Solution 1:

I figured it out!

managers.py

from model_utils.managers import InheritanceQuerySet

classUserManager([...]):

    defget_queryset(self):
        return InheritanceQuerySet(self.model).select_subclasses()

I didn't have to inherit InheritanceManager, instead use the InheritanceQuerySet.

Post a Comment for "Automatically Downcast To Subclass Using Django-model-utils"