Skip to content

Commit

Permalink
Bring back auto_now_add for dates (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei authored Feb 23, 2024
1 parent 87bfc3a commit bd1c6a1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.10 on 2024-02-23 09:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("donations", "0009_alter_donor_date_created_alter_ngo_date_created"),
]

operations = [
migrations.AlterField(
model_name="donor",
name="date_created",
field=models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created"),
),
migrations.AlterField(
model_name="ngo",
name="date_created",
field=models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created"),
),
]
4 changes: 2 additions & 2 deletions backend/donations/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Ngo(models.Model):
upload_to=partial(year_ngo_directory_path, "ngo-forms"),
)

date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True)
date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True, auto_now_add=timezone.now)
date_updated = models.DateTimeField(verbose_name=_("date updated"), db_index=True, auto_now=timezone.now)

objects = models.Manager()
Expand Down Expand Up @@ -293,7 +293,7 @@ class Donor(models.Model):
upload_to=partial(year_ngo_donor_directory_path, "donation-forms"),
)

date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True)
date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True, auto_now_add=timezone.now)

class Meta:
verbose_name = _("donor")
Expand Down
18 changes: 18 additions & 0 deletions backend/users/migrations/0006_alter_user_date_created.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.10 on 2024-02-23 09:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("users", "0005_alter_user_date_created"),
]

operations = [
migrations.AlterField(
model_name="user",
name="date_created",
field=models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date created"),
),
]
4 changes: 2 additions & 2 deletions backend/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class User(AbstractUser):

old_password = models.CharField(verbose_name=_("old password"), max_length=128, blank=True, null=True)

date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True)
date_updated = models.DateTimeField(verbose_name=_("date updated"), auto_now=timezone.now, db_index=True)
date_created = models.DateTimeField(verbose_name=_("date created"), db_index=True, auto_now_add=timezone.now)
date_updated = models.DateTimeField(verbose_name=_("date updated"), db_index=True, auto_now=timezone.now)

objects = CustomUserManager()

Expand Down

0 comments on commit bd1c6a1

Please sign in to comment.