From 63461f5b124a27be1da1b606d884b1043ed23879 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 21 Feb 2025 15:50:47 +0000 Subject: [PATCH] Fix issue #197: Add timestamps to models demo --- ...eated_at_collection_updated_at_and_more.py | 67 +++++++++++++++++++ photo/models.py | 2 + 2 files changed, 69 insertions(+) create mode 100644 photo/migrations/0005_collection_created_at_collection_updated_at_and_more.py diff --git a/photo/migrations/0005_collection_created_at_collection_updated_at_and_more.py b/photo/migrations/0005_collection_created_at_collection_updated_at_and_more.py new file mode 100644 index 0000000..79efe8f --- /dev/null +++ b/photo/migrations/0005_collection_created_at_collection_updated_at_and_more.py @@ -0,0 +1,67 @@ +# Generated by Django 4.2.8 on 2025-02-21 15:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("photo", "0004_alter_contest_prize"), + ] + + operations = [ + migrations.AddField( + model_name="collection", + name="created_at", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name="collection", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + migrations.AddField( + model_name="contest", + name="created_at", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name="contest", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + migrations.AddField( + model_name="contestsubmission", + name="created_at", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name="contestsubmission", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + migrations.AddField( + model_name="picture", + name="created_at", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name="picture", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + migrations.AddField( + model_name="picturecomment", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + migrations.AddField( + model_name="user", + name="created_at", + field=models.DateTimeField(auto_now_add=True, null=True), + ), + migrations.AddField( + model_name="user", + name="updated_at", + field=models.DateTimeField(auto_now=True, null=True), + ), + ] diff --git a/photo/models.py b/photo/models.py index 85d4a52..bbd5e0f 100644 --- a/photo/models.py +++ b/photo/models.py @@ -48,6 +48,8 @@ def create_superuser(self, email, password=None, **kwargs): class SoftDeleteModel(models.Model): is_deleted = models.BooleanField(default=False) + created_at = models.DateTimeField(null=True, blank=True, auto_now_add=True) + updated_at = models.DateTimeField(null=True, blank=True, auto_now=True) objects = SoftDeleteManager() all_objects = models.Manager()