Skip to content

Commit

Permalink
Make the created_at and last_modified_at fields non-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
harriris-vincit committed Aug 14, 2023
1 parent c336b39 commit 2f1d147
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions registrations/migrations/0017_created_modified_info_to_signup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 3.2.20 on 2023-08-10 10:03
# Generated by Django 3.2.20 on 2023-08-14 06:22

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):
Expand All @@ -21,8 +22,11 @@ class Migration(migrations.Migration):
model_name="signup",
name="created_at",
field=models.DateTimeField(
auto_now_add=True, null=True, verbose_name="Created at"
auto_now_add=True,
default=django.utils.timezone.now,
verbose_name="Created at",
),
preserve_default=False,
),
migrations.AddField(
model_name="signup",
Expand All @@ -38,9 +42,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="signup",
name="last_modified_at",
field=models.DateTimeField(
auto_now=True, null=True, verbose_name="Modified at"
),
field=models.DateTimeField(auto_now=True, verbose_name="Modified at"),
),
migrations.AddField(
model_name="signup",
Expand All @@ -55,9 +57,12 @@ class Migration(migrations.Migration):
),
migrations.AlterField(
model_name="registration",
name="created_at",
name="last_modified_at",
field=models.DateTimeField(
auto_now_add=True, null=True, verbose_name="Created at"
auto_now=True,
default=django.utils.timezone.now,
verbose_name="Modified at",
),
preserve_default=False,
),
]
4 changes: 2 additions & 2 deletions registrations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def formfield(self, **kwargs):
class CreatedModifiedBaseModel(models.Model):
created_at = models.DateTimeField(
verbose_name=_("Created at"),
null=True,
null=False,
blank=True,
auto_now_add=True,
)
last_modified_at = models.DateTimeField(
verbose_name=_("Modified at"),
null=True,
null=False,
blank=True,
auto_now=True,
)
Expand Down

0 comments on commit 2f1d147

Please sign in to comment.