From 1f4a665fe31869b4cbcafc00059a0179e1d76e5e Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Tue, 29 Apr 2014 14:36:51 -0400 Subject: [PATCH] Make the deletion check a default filter on the base model, inherited by subclasses of the base model. --- planetstack/core/models/plcorebase.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py index e6c9f6d..0e7b463 100644 --- a/planetstack/core/models/plcorebase.py +++ b/planetstack/core/models/plcorebase.py @@ -16,6 +16,8 @@ except: def notify_observer(): pass +# This manager will be inherited by all subclasses because +# the core model is abstract. class PlCoreBaseManager(models.Manager): def get_query_set(self): return super(PlCoreBaseManager, self).get_query_set().filter(deleted=False) @@ -30,6 +32,8 @@ class PlCoreBase(models.Model): deleted = models.BooleanField(default=False) class Meta: + # Changing abstract to False would require the managers of subclasses of + # PlCoreBase to be customized individually. abstract = True app_label = "core" -- 2.47.0