Hi,
i have a model with a m2m:
class PiattoPersonalizzato(models.Model):
descrizione = models.CharField(max_length=80)
categoria = models.ForeignKey(Categoria)
numero = models.IntegerField(default=1)
ingredienti = models.ManyToManyField(Ingrediente,default=None,null=True,blank=True)
prezzo = models.DecimalField(max_digits=15, decimal_places=2, default=0)
def __unicode__(self):
return self.descrizione
class Meta:
verbose_name_plural = "Piatti Personalizzati"
I need to use the difference function, so
piattoPersonalizzato = [... get the object model ... ]
piatto = [... get the object model ... ]
[...]
ingredientiPiattoComanda = piatto.ingredienti.all()
ingredientiPiattoPersonalizzato = piattoPersonalizzato.ingredienti.all()
intersezione = set(ingredientiPiattoComanda).difference(set(ingredientiPiattoPersonalizzato))
[...]
It is possible do it using django database function? Do it cost a lot of memory, i want to do it using database...
regards,
Vanni