From 17d9195eba18147bc4e9f21e164d34fc4d9c841e Mon Sep 17 00:00:00 2001 From: Mohamed Mansor Date: Sun, 12 Nov 2023 00:06:43 +0200 Subject: [PATCH] Add Model Style guide --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4712175..05c00f8 100644 --- a/README.md +++ b/README.md @@ -218,11 +218,12 @@ Models should take care of the data model and not much else. ### Base model It's a good idea to define a `BaseModel`, that you can inherit. - -Usually, fields like `created_at` and `updated_at` are perfect candidates to go into a `BaseModel`. - Defining a primary key can also go there. Potential candidate for that is the [`UUIDField`](https://docs.djangoproject.com/en/dev/ref/models/fields/#uuidfield) +At Shahry We're using `TimeStampedModel` which has `created` and `updated` fields + +Since all models should be audit logs the `BaseModel` Should has `AuditLogModel`. + Here's an example `BaseModel`: ```python @@ -230,9 +231,7 @@ from django.db import models from django.utils import timezone -class BaseModel(models.Model): - created_at = models.DateTimeField(db_index=True, default=timezone.now) - updated_at = models.DateTimeField(auto_now=True) +class BaseModel(AuditLogModel, TimeStampedModel): class Meta: abstract = True