Hi
I fairly often have code that looks like
Model.objects.filter(id__in=some_list)
where some_list is generated programatically. Sometimes some_list is
empty, and if it is, I get a psycopg.ProgrammingError exception. OTOH if I
use SQLite I simply get back an empty query-set as expected.
Is
On Fri, 21 Jul 2006 09:50:15 +1000, Malcolm Tredinnick wrote:
> Because of the way QuerySets are constructed, there's no easy way to
> tell when a user is walking into this case. The current behaviour may
> reasonably be considered a semi-bug, however it's unavoidable at the
> moment since we
Malcolm,
On Thu, 20 Jul 2006 16:56:22 +1000, Malcolm Tredinnick wrote:
>> > I think you want to use:
>> >
>> > Image.objects.filter(tags__id__in=[1,2]).distinct()
>>
>> Alas, this returns all the images with tag1 OR tag2. I'm looking for
>> images with tag1 AND tag2.
>
> Here's a solution
Matthew,
Thanks for the info.
On Thu, 20 Jul 2006 10:05:43 +1000, Matthew Flanagan wrote:
>> In [73]:Image.objects.filter(tags__id=1).filter(tags__id=2)
>> Out[73]:[]
>>
>
> I think you want to use:
>
> Image.objects.filter(tags__id__in=[1,2]).distinct()
Alas, this returns all the images
Hi
A photo-app I'm working on has tags on an image defined as a many to many
relationship:
class Image(models.Model):
filename = models.CharField(maxlength=255)
description = models.TextField()
tags = models.ManyToManyField(Tag)
Given several tags: TagA, TagB, ..., I'm trying to
Hi
On Thu, 08 Jun 2006 23:07:51 -0400, Todd O'Bryan wrote:
> And then I need to be running under program control again to add all
> my test data to the the db.
>
> Please tell me that I'm overthinking this and there's some easy way
> out of this!
The other posters in this thread do give
6 matches
Mail list logo