I'm trying to access a model in reverse. To access the Vale model by consulting the model DetailVale is as follows:
val= DetalleVale.objects.filter(vale__usuarioVale=usuario).filter(vale__statusFinalizado=1)
However I need to consult about the Vale model and through this arrive at the properties of DetalleVale and be able to use the fields cardboard, name, part, etc.
My models:
class Vale(models.Model):
fechaCreacion = models.DateTimeField(auto_now_add=True)
linea = models.IntegerField(choices=LINEAS.CHOICES_LINEAS, default=LINEAS.SELECCIONAR)
lote = models.TextField(max_length=50)
turno = models.IntegerField(choices=TURNOS.CHOICES_TURNOS, default=TURNOS.SELECCIONAR)
usuarioVale = models.ForeignKey(User)
statusFinalizado = models.IntegerField(default=0)
statusAutorizacion=models.IntegerField(choices=ESTADOS.CHOICES_ESTADOS, default=ESTADOS.SELECCIONAR)
vigenciaVale = models.IntegerField(choices=STATUSVALE.CHOICES_STATUSVALE, default=STATUSVALE.ACTIVO)
class Meta:
verbose_name = 'Vales'
verbose_name_plural = 'Vale'
def __str__(self):
return '%s' % (self.id)
class DetalleVale(models.Model):
fechaCreacion = models.DateTimeField(auto_now_add=True)
vale = models.ForeignKey(Vale)
cartonNo = models.CharField(max_length=50)
nombreM = models.CharField(max_length=50, null=True)
parte = models.CharField(max_length=50, null=True)
descripcion = models.CharField(max_length=50, null=True)
multiplo = models.IntegerField()
cantidad = models.IntegerField(default=1)