Hey,

Ok I have a queryset that basically searches a model for both the
title, and the title of related tags.

================
File: views.py
================
query = request.POST.get('blog', '')
        if query:
                qset = (
                        Q(tags__title__icontains=query) | 
Q(title__icontains=query)
                )
                results = Blog.objects.filter(qset).distinct()
        else:
                results = Blog.objects.all()

================
File: models.py
================

class Tag(models.Model):
        title = models.CharField(maxlength=100)

class Blog(models.Model):
        title = models.CharField(maxlength=100)
        tags = models.ManyToManyField(Tag, blank=True)



Basically, the queryset in views.py will ONLY return results if that
particular Blog has a Tag related to it. If I haven't specified a tag
for a particular blog, it will NEVER appear in my results.

Any ideas? Is my query only getting results with both a TITLE and
TAG_TITLE?

Cheers,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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