scoursen / django-softdelete

Soft delete for Django ORM, with support for undelete.
Other
376 stars 102 forks source link

Allow SoftDeleteManager to use custom queryset #69

Closed pcarn closed 4 years ago

pcarn commented 4 years ago

I am not able to use SoftDeleteManager with a custom queryset. Here's what I'm attempting to do:

class CustomQuerySet(SoftDeleteQuerySet):
    def unanswered(self):
        return self.filter(response=None)

CustomManager = SoftDeleteManager.from_queryset(CustomQuerySet)

class Model:
    ...
    objects = CustomManager()

When I do Model.objects.unanswered(), I get AttributeError: 'SoftDeleteQuerySet' object has no attribute 'unanswered' It's because in SoftDeleteManager, it is overriding the queryset class to SoftDeleteQuerySet. But in my situation, I want to use my custom queryset that inherits from SoftDeleteQuerySet.

I propose only overriding the queryset class if the current queryset class is not a subclass of SoftDeleteQuerySet.

PeterCarnesciali-minted commented 4 years ago

@scoursen Have you had a chance to look at this? I'd need this change to be able to use django-softdelete.