From cdd9dfae6c8757302d366c1c135ad72e1cbd0016 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 17 Apr 2020 21:13:16 +0000 Subject: [PATCH] Provide default value for email_change_date and don't allow it to be null --- users/migrations/0088_auto_20200417_2312.py | 23 +++++++++++++++++++++ users/models.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 users/migrations/0088_auto_20200417_2312.py diff --git a/users/migrations/0088_auto_20200417_2312.py b/users/migrations/0088_auto_20200417_2312.py new file mode 100644 index 00000000..e9f82f7c --- /dev/null +++ b/users/migrations/0088_auto_20200417_2312.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.28 on 2020-04-17 21:12 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0087_request_email'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='email_change_date', + field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2020, 4, 17, 21, 12, 19, 739799, tzinfo=utc)), + preserve_default=False, + ), + ] diff --git a/users/models.py b/users/models.py index 1baac3a8..613aa9ef 100755 --- a/users/models.py +++ b/users/models.py @@ -238,7 +238,7 @@ class User( shortcuts_enabled = models.BooleanField( verbose_name=_("enable shortcuts on Re2o website"), default=True ) - email_change_date = models.DateTimeField(default=None, null=True) + email_change_date = models.DateTimeField(auto_now_add=True) USERNAME_FIELD = "pseudo" REQUIRED_FIELDS = ["surname", "email"]