跟踪:
触发错误的视图是这样的:
class Order(models.Model):
fecha_reparto = models.ForeignKey(DiasDeReparto, on_delete=models.CASCADE, default= 1)
order_nodo = models.ForeignKey(Nodo, on_delete=models.CASCADE, default= 1)
ref_code = models.CharField(max_length=15)
owner = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
is_ordered = models.BooleanField(default=False)
date_ordered = models.DateTimeField(null=True)
型号:
SELECT a.*, (case when exists (select 1
from b inner join
c
on b.value = c.value
where b.customer = a.customer and
c.item = a.item
)
then 1 else 0
end) as valuematch
FROM a;