1

I override delete method (have made object non-deleteable and set 'active' field to false) in custom QuerySet in custom ModelManager. Is there any way to ignore custom manager in admin panel so I can actually delete objects from there?

edit 1

First thought: I can specify another name for custom Manager. But now it's treated as default... And how to bypass obj.delete()?

edit 2

Solution for first problem is to add custom manager alongside with default:

objects = models.Manager()
active_manager = EventManager()

Solution to second problem is to add param to the custom delete method:

def delete(self, *args, **kwargs):
    force = kwargs.pop('force', False)
    ...
aiven
  • 3,775
  • 3
  • 27
  • 52

1 Answers1

1

You can add parameter to your custom delete method. for example:

def delete(self, super=True):
    if super:
         return self.get_queryset().delete()
    else:
        # Your custom code here
Brown Bear
  • 19,655
  • 10
  • 58
  • 76