
Models Abstract Bases
- 1 installs
- Updated May 22, 2026
- engremran07/gsmvault
Choose and use Django abstract base models - TimestampedModel, SoftDeleteModel, AuditFieldsModel - so every new model inherits standard fields consistently.
About
Defines the project's abstract base model hierarchy (TimestampedModel, SoftDeleteModel, AuditFieldsModel) and when to inherit each. A developer uses it when creating a new Django model or choosing its base class.
- All models inherit TimestampedModel at minimum, never bare Model
- SoftDeleteModel for recoverable records, AuditFieldsModel for created_by tracking
Models Abstract Bases by the numbers
- 1 all-time installs (skills.sh)
- Ranked #770 of 911 Databases skills by installs in the Skillselion catalog
- Data as of Jul 8, 2026 (Skillselion catalog sync)
npx skills add https://github.com/engremran07/gsmvault --skill models-abstract-basesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| Last updated | May 22, 2026 |
| Repository | engremran07/gsmvault ↗ |
What it does
Choose and use Django abstract base models - TimestampedModel, SoftDeleteModel, AuditFieldsModel - so every new model inherits standard fields consistently.
Files
Abstract Base Models
When to Use
- Creating any new model in the project
- Choosing between
TimestampedModel,SoftDeleteModel,AuditFieldsModel - Understanding what fields are inherited from base classes
Rules
- ALL models MUST inherit from
TimestampedModelat minimum — never baremodels.Model - Import from
apps.core.models(the re-export shim), NOTapps.site_settings.models SoftDeleteModelfor content that users may want to restoreAuditFieldsModelfor admin-managed records needingcreated_by/updated_bytracking- Never re-implement
created_at/updated_at— they come fromTimestampedModel
Patterns
TimestampedModel — Default Base
from apps.core.models import TimestampedModel
class Brand(TimestampedModel):
"""Every model inherits created_at and updated_at automatically."""
name = models.CharField(max_length=255, unique=True)
slug = models.SlugField(max_length=255, unique=True)
logo = models.ImageField(upload_to="brands/", blank=True)
def __str__(self) -> str:
return self.name
class Meta:
db_table = "firmwares_brand"
verbose_name = "Brand"
verbose_name_plural = "Brands"
ordering = ["name"]SoftDeleteModel — Recoverable Deletion
from apps.core.models import SoftDeleteModel
class ForumTopic(SoftDeleteModel):
"""Adds is_deleted, deleted_at fields. Use .objects for active, .all_objects for everything."""
title = models.CharField(max_length=300)
category = models.ForeignKey("ForumCategory", on_delete=models.CASCADE, related_name="forum_topics")
def __str__(self) -> str:
return self.title
class Meta:
db_table = "forum_forumtopic"
ordering = ["-created_at"]AuditFieldsModel — Admin Tracking
from apps.core.models import AuditFieldsModel
class BlogPost(AuditFieldsModel):
"""Adds created_by, updated_by FKs tracking who made changes."""
title = models.CharField(max_length=300)
content = models.TextField()
status = models.CharField(max_length=20, choices=[("draft", "Draft"), ("published", "Published")])
def __str__(self) -> str:
return self.title
class Meta:
db_table = "blog_blogpost"
ordering = ["-created_at"]Choosing the Right Base
| Base Class | Use For | Extra Fields |
|---|---|---|
TimestampedModel | Default for all models | created_at, updated_at |
SoftDeleteModel | User-generated content, forum posts | + is_deleted, deleted_at |
AuditFieldsModel | Admin-managed records | + created_by, updated_by |
Combining with Mixins
from apps.core.models import TimestampedModel
class StatusMixin(models.Model):
"""Reusable mixin — NOT a standalone model."""
is_active = models.BooleanField(default=True)
status = models.CharField(max_length=20, default="draft")
class Meta:
abstract = True
class Product(StatusMixin, TimestampedModel):
name = models.CharField(max_length=255)
price = models.DecimalField(max_digits=10, decimal_places=2)
class Meta:
db_table = "shop_product"Anti-Patterns
- Inheriting from bare
models.Model— always useTimestampedModel - Importing base models from
apps.site_settings.modelsdirectly — useapps.core.models - Re-defining
created_at/updated_aton a model — already inherited - Making abstract base classes non-abstract (missing
abstract = Truein Meta)
Quality Gate
& .\.venv\Scripts\python.exe -m ruff check . --fix
& .\.venv\Scripts\python.exe -m ruff format .
& .\.venv\Scripts\python.exe manage.py check --settings=app.settings_devReferences
apps/core/models.py— re-export shimapps/site_settings/models.py— actual base class definitions
Related skills
Databasesdatabases