Documentation of the abstract base models in the Core app

Core App Data Models Documentation

Brand values alignment: All features and data models should align with Courtex values: Community, Transparency, Accessibility, Integrity, Humility. See docs/markdown/brand/copilot-instructions.md for full guidance.

Overview

The Core app provides shared abstract base models that are inherited by models across the entire Courtex application. It does not define any concrete database tables itself.

Abstract Models

1. TimeStampedModel

The TimeStampedModel is an abstract base model that provides standard timestamp fields for tracking record lifecycle. All major domain models across the application inherit from this class.

Key Fields: - created_at: Auto-set datetime when the record is first created (auto_now_add=True) - updated_at: Auto-updated datetime whenever the record is saved (auto_now=True) - deleted_at: Nullable datetime used for soft-deletion (set manually; null=True, blank=True)

Meta: - abstract = True — no database table is created - get_latest_by = 'updated_at' — default ordering for latest() queries

Business Logic: - Soft-delete pattern: instead of deleting records from the database, set deleted_at to the current timestamp - The deleted_at field is not automatically managed — it must be set explicitly in business logic - All apps that need timestamped or soft-deleteable records should inherit from this model

Apps that use TimeStampedModel: - usersUser, Plan, Subscription - clubsClub - sport_sessionsSession, SessionTemplate, RSVP - matchesMatch, MatchProgression, Note - financeTransaction (abstract), Income, Expense - paymentsStripeWebhookEvent - articlesArticle - mmr — (not used; MMR uses plain models.Model)


Notes

  • The core app also contains base test utilities and factory helpers used across the test suite.
  • There are no concrete models in this app — no migrations will include core model tables.