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))
if not intersezione:
[...]
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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d7be07b3-a434-4f5c-bd80-6418fd15c489%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment