diff --git a/app/users/migrations/0002_alter_customuser_email.py b/app/users/migrations/0002_alter_customuser_email.py new file mode 100644 index 00000000..7ed93a3a --- /dev/null +++ b/app/users/migrations/0002_alter_customuser_email.py @@ -0,0 +1,21 @@ +# Generated by Django 3.2.15 on 2022-11-08 11:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [("users", "0001_initial")] + + operations = [ + migrations.AlterField( + model_name="customuser", + name="email", + field=models.EmailField( + error_messages={"unique": "A user with that email already exists."}, + max_length=254, + unique=True, + verbose_name="email address", + ), + ) + ] diff --git a/app/users/models.py b/app/users/models.py index 659ac76b..2bd39b90 100644 --- a/app/users/models.py +++ b/app/users/models.py @@ -1,5 +1,13 @@ from django.contrib.auth.models import AbstractUser +from django.utils.translation import gettext_lazy as _ +from django.db.models import EmailField class CustomUser(AbstractUser): - pass + email = EmailField( + _("email address"), + blank=False, + error_messages={"unique": _("A user with that email already exists.")}, + null=False, + unique=True, + )