StatusModel status managers don't have custom methods of a default manager
EliasCampos opened this issue · 0 comments
Problem
Sometimes you might want to add a custom manager with custom queryset methods to a model that inherits StatusModel
. (for example, via .as_manager()
method of a queryset class):
class CustomQuerySet(models.QuerySet):
def custom_qs_method(self):
return self.filter(feedback='')
class Consultation(StatusModel):
STATUS = Choices('PENDING', 'FINISHED')
feedback = models.TextField(default='')
objects = CustomQuerySet.as_manager()
Later, you might need to apply the methods to a queryset that filtered by a status value. I guess, it would be nice to use a manager for a specific status, provided by StatusModel
(in this way we don't need to add .filter(status=value)
each time or to define extra methods in custom managers). So, It would be nice to be able to do something like that:
Consultation.FINISHED.custom_qs_method()
But currently it's not possible, because status manager is a QueryManager
instance, and it doesn't inherit a custom methods of default manager. I propose to complement current implementation of the status managers, to include custom qs/manager methods to a status manager.