Hey guys, I'm having a problem that I don't know if there is any feature that I can use to filter a list in django. What I'm trying to do is to use a manual get_or_create. I have the following models: class STREAM(models.Model): stream_inds = models.ManyToManyField('STREAM_Ind') Type = models.CharField(max_length = 5) Throughput = models.DecimalField(max_digits = 15, decimal_places = 3)
class STREAM_Ind(models.Model): Port = models.IntegerField() Throughput = models.DecimalField(max_digits = 15, decimal_places = 3) What I've tried to do so far is this: try: qset = ( Q(stream_inds__pk__iexact = ids) & Q(Type__iexact = type) & Q(Throughput__iexact = throughput) ) streams = STREAM.objects.select_related().filter(qset).distinct().get() except STREAM.DoesNotExist: fields = { 'Type': type, 'Throughput': throughput, } form = STREAMForm(fields) streams = form.save() The third line is where I think the problem is, ids is a variable that contains a list of id that are supposed to match with all the primary keys of the STREAM_Ind model. So I can be sure that the data is already in the database, but the first Q object i think always return false. Is there some way to do it? (I thought about using the "in" feature, but I need to make sure all pk are matched in order to retrieve the object, not just one of them). Is there a feature that allow me to do that? If not can you guys give me a hint of what am I supposed to do? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.