I have a question about RSS feeds for objects by tag.

I'm using this statement currently in a feed class items method, which
accepts a tag as an 'obj' parameter:

return Model.objects.filter(tags__icontains=obj.name).order_by('-
pub_date')[:10]

This statement works, but I get mixed results in my QuerySet based on
whether I filter by 'icontains' or 'exact'.

For example, filtering for the tag 'test' matches 'test', 'tag-
testing', and 'testing'. I only want objects tagged with 'test'. If I
use the 'exact' lookup, if the field contains more than one tag, it
won't find the tag at all.

I know there's a good generic view for this, tagged_object_list, but I
need a request object to use it, and my feed class doesn't accept or
create request objects that I know of.

How would I translate the following sql query into a chained QuerySet
statement:

select *
from model m
        inner join taggeditem ti
                on m.id = ti.object_id
        inner join tag t
                on ti.tag_id = t.id
where t.name = obj.name

Is there a better way to do this? The problem with the TagField() is
it can be multivalued.

Is there a way to split a tag field and then do a match on each item
in the list?

Any suggestions?

I'm scripting in Django 1.1, using postgreSQL, and Windows XP.

Thank you very much.

Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to