You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.4 KiB

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.utils.translation import gettext_lazy as _
from .managers import ReyMotaUserManager
# Create your models here.
class ReyMotaUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(_("email address"), unique=True)
foto = models.ImageField(upload_to="profile_images", default="profile_images/default.jpg", blank=True)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
nombre = models.CharField(max_length=200, blank=True, null=True)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
objects = ReyMotaUserManager()
def __str__(self):
return self.email
class Tipos(models.Model):
tipo = models.TextField(max_length=10)
class Cuentas(models.Model):
nombre = models.TextField(max_length=20)
saldo_inicial = models.DecimalField(max_digits=10, decimal_places=2)
saldo_actual = models.DecimalField(max_digits=10, decimal_places=2)
tipo = models.ForeignKey(Tipos, on_delete=models.CASCADE)
class Apuntes(models.Model):
fecha = models.DateField()
cta_origen = models.ForeignKey(Cuentas, on_delete=models.CASCADE, related_name='origen')
cta_destino = models.ForeignKey(Cuentas, on_delete=models.CASCADE, related_name='destino')
importe = models.DecimalField(max_digits=10, decimal_places=2)