Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified essenza/db.sqlite3
Binary file not shown.
6 changes: 6 additions & 0 deletions essenza/essenza/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,9 @@
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# -----------------------------------------------------------------
# SOLUCIÓN AL ERROR E304
# Especifica que nuestro modelo 'Usuario' en la app 'user'
# es el modelo de autenticación oficial.
# -----------------------------------------------------------------
AUTH_USER_MODEL = 'user.Usuario'
2 changes: 1 addition & 1 deletion essenza/product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Product(models.Model):
categoria = models.CharField(max_length=20, choices=Category.choices)
brand = models.CharField(max_length=255)
price = models.DecimalField(max_digits=10, decimal_places=2)
foto = models.URLField(blank=True, null=True)
foto = models.ImageField(upload_to='profile_pics/', null=True, blank=True)
stock = models.IntegerField()
is_active = models.BooleanField(default=False)

Expand Down
Binary file added essenza/profile_pics/img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added essenza/profile_pics/user1.avif
Binary file not shown.
Binary file added essenza/profile_pics/user2.avif
Binary file not shown.
Binary file added essenza/profile_pics/user3.avif
Binary file not shown.
Binary file added essenza/static/images/img2.avif
Binary file not shown.
17 changes: 5 additions & 12 deletions essenza/user/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
from django.db import models
from django.contrib.auth.models import AbstractUser

# Create your models here.
class Role(models.TextChoices):
ADMIN = 'admin', 'Admin'
USER = 'user', 'User'


class Usuario(models.Model):
name = models.CharField(max_length=255)
email = models.EmailField(max_length=255, unique=True)
foto = models.URLField(blank=True, null=True)
password = models.CharField(max_length=255)
class Usuario(AbstractUser):
foto = models.ImageField(upload_to='images/', null=True, blank=True)
role = models.CharField(max_length=10, choices=Role.choices, default=Role.USER)


def __str__(self):
return self.email

# user1@example.com, user
# user2@example.com, user
# admin1@example.com, admin
return self.username