diff --git a/README.md b/README.md index c3711a8..18d28ef 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,7 @@ Lista de la compra #### Commit 4 - 00:48:30 + +#### Commit 5 + +- 00:53:00 diff --git a/authentication/admin.py b/authentication/admin.py index 8c38f3f..73b6440 100644 --- a/authentication/admin.py +++ b/authentication/admin.py @@ -1,3 +1,10 @@ from django.contrib import admin +from authentication.models import User + + +@admin.register(User) +class UserAdmin(admin.ModelAdmin): + pass + # Register your models here. diff --git a/authentication/migrations/0001_initial.py b/authentication/migrations/0001_initial.py index 0d511fc..6e89c1b 100644 --- a/authentication/migrations/0001_initial.py +++ b/authentication/migrations/0001_initial.py @@ -1,6 +1,6 @@ -# Generated by Django 4.1.7 on 2023-02-17 17:48 +# Generated by Django 4.1.7 on 2023-02-19 20:53 -import django.contrib.auth.models +import django.contrib.auth.validators from django.db import migrations, models import django.utils.timezone @@ -21,12 +21,13 @@ class Migration(migrations.Migration): ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), - ('email', models.EmailField(max_length=80, unique=True)), + ('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), ], @@ -35,8 +36,5 @@ class Migration(migrations.Migration): 'verbose_name_plural': 'users', 'abstract': False, }, - managers=[ - ('objects', django.contrib.auth.models.UserManager()), - ], ), ] diff --git a/authentication/models.py b/authentication/models.py index 3569c90..ce13671 100644 --- a/authentication/models.py +++ b/authentication/models.py @@ -1,7 +1,6 @@ from django.contrib.auth.models import AbstractUser, models from django.contrib.auth.base_user import BaseUserManager from django.utils.translation import gettext_lazy as _ -from django.db import models class CustomUserManager(BaseUserManager): @@ -10,7 +9,7 @@ class CustomUserManager(BaseUserManager): if not email: raise ValueError(_("El email es necesario")) email = self.normalize_email(email) - new_user = self.model(email=email) + new_user = self.model(email=email, **extra_fields) new_user.set_password(password) new_user.save() return new_user @@ -29,8 +28,9 @@ class CustomUserManager(BaseUserManager): class User(AbstractUser): - username = None - email = models.EmailField(max_length=80, unique=True) + email = models.EmailField(_('email address'), unique=True) + + objects = CustomUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] diff --git a/listaCompra/settings.py b/listaCompra/settings.py index 8cca389..b02a06a 100644 --- a/listaCompra/settings.py +++ b/listaCompra/settings.py @@ -81,7 +81,8 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [ { 'NAME': - 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + 'django.contrib.auth.password_validation' + + '.UserAttributeSimilarityValidator', }, { 'NAME':