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.
 
 
 
 
 

36 lines
1.4 KiB

from django.db import models
import datetime
from django.core.validators import MaxValueValidator, MinValueValidator
from django.utils.translation import gettext_lazy as _
def current_year():
return datetime.date.today().year
def max_value_current_year(value):
return MaxValueValidator(current_year())(value)
class Vehiculo(models.Model):
marca = models.CharField(max_length=200)
modelo = models.CharField(max_length=200)
matricula = models.CharField(max_length=200)
foto = models.ImageField(upload_to='vehiculos/', blank=True, null=True) # Nuevo campo
def __str__(self):
return self.marca
class Repostaje(models.Model):
vehiculo = models.ForeignKey(Vehiculo, on_delete=models.CASCADE)
fecha = models.DateField()
kms = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
litros = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
descuento = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
importe = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
precioxlitro = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
kmsrecorridos = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
consumo = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
def __str__(self):
return self.fecha