Django: Creating a Mixin for Reusable Model Fields
Abstract models still need to inherit from model.Model
to work correctly:
class TrackingFieldsMixin(models.Model):
Also instead of your active
BooleanField
I would add a deleted_on
DateTimeField
so you can record when the record was deleted. You can then just add properties on the instance to see if it's active:
@propertydef active(self): return self.deleted_on is None
and in queries and/or a custom manager:
Blog.objects.filter(deleted_on__isnull=True)