Tagging 12.24.2006

I just added the tagging retrieval methods.

Previously, tagging was allowed — in that they were in the database — but there wasn’t anything in place to actually retrieve those entries tagged with a specific tag. Now there is!

It was incredibly simple:

def tags(request, tag):
    tags =  Entry.objects.filter(tags__name=tag)
    return object_list(request, queryset=tags, template_name=’blog/tags.html’, extra_context={‘tag’:tag})

That’s it.

It’s a view that wraps the generic object_list view in a custom view that filters the set it receives. It also adds in an extra context so the page can display which tag was invoked.

All in all, it took about 5 minutes to do some research on the specifics on the filter() specifics, 5 minutes to lookup relevant info about the object_list view and type out my wrapper view, and 2 minutes to find how to make inline code chunks in Markdown (you use backquotes, for future reference).