Hi Chris,

> ---snip---
> class RequestParameters(models.Model):
>   parameter = models.CharField(max_length=64)
>   value = models.CharField(max_length=64)
>
> class Request(models.Model):
>   locale = models.CharField(max_length=32, default=LOCALES[1][0],
> choices=LOCALES)
>   lastCheck = models.DateTimeField(blank=True, null=True)
>   parameters = models.ManyToManyField(RequestParameters)
>   users = models.ManyToManyField(User)
> ---snip---
>
> And I'm trying  to query for an Item with two "RequestParmeter"s (both
> of them, mysql AND) I thought I could use two Q Objects and combine
> them using & but for some reason this will not work:
> ---snip--
> In [309]: Request.objects.filter(Q(parameters=1))
> Out[309]: [<Request: 1>, <Request: 2>]
> In [310]: Request.objects.filter(Q(parameters=2))
> Out[310]: [<Request: 1>, <Request: 2>, <Request: 3>]
> In [311]: Request.objects.filter(Q(parameters=1)&Q(parameters=2))
> Out[311]: []
> ---snip---
>
> Can someone point me to my error? thanks in advance,

Try:
Request.objects.filter(parameters=1, parameters=2)

This assumes that you are on the latest svn trunk of Django (in
particular, a trunk after the QuerySet refactor branch was merged in
to trunk.)

See: 
http://code.djangoproject.com/wiki/QuerysetRefactorBranch#Backwardsincompatiblechanges

-Rajesh D

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to