Hello,

I'm using the `django-tagging`v0.3.0( http://code.google.com/p/django-tagging/
) app for tagging my blog posts (obviously).

Now I wanted to create a view, which takes a tag and returns all
related posts, posts which have the same tag.

My code:

from tagging.views import tagged_object_list

def by_tag(request, tag, *args, **kwargs):
    """Post listing. Only shows posts that belong to specified tags"""
    queryset = Post.objects.all()
    if not kwargs.has_key('extra_context'):
        kwargs['extra_context'] = {}
    kwargs['extra_context']['feedurl'] = 'tag/%s' % tag
    def tagged_objects(taglist, union):
        return tagged_object_list(request, queryset, taglist,
union=union,
                                  *args, **kwargs)
    if '+' in tag:
        return tagged_objects(tag.split('+'), False)
    else:
        return tagged_objects(tag.split('|'), True)

If this gets called giving an *existing* tag, it returns this:

      No Tag found matching "[u'test']".

Is there any better way to do this?

--

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