« Luck and a New Life in Lawrence | Testmaker 0.2: Rewritten and improved »
I have been doing some more work on my Django Community Aggregator / Django People v2 project. A big feature that I want to incorporate is tagging. I want people to be able to sort data by tag, among other things. I think that this is a pretty killer feature.
This allows someone to say "I want to get all of the data about testing or debugging that the Django community is doing". However, if nobody is tagging their posts, then only services that provide tags will be available in those views. A lot of people are using django-tagging on the backend of their blogs, but they just aren't exposing that data in feeds.
Note: Yes I know the data can't be edited yet (on the aggregator). That is because it is a project that is just living on my site for the moment. Once it gets moved off and the Uber community of Django gets more off the ground, all of those issues will be solved.
Luckily, it is really easy to expose your tagging data in your Django feeds. This assumes you are using Django Tagging, however, it's really easy with anything else.
Say we have our feed class that looks like this.
class BlogPostsFeed(Feed):
title = 'My awesome blog'
description = 'My awesome blog"
def link(self):
return "http://mysite.com"
def items(self):
return Post.objects.published()[:10]
def item_pubdate(self, obj):
return obj.publish
That is a pretty basic feed, but much akin to what most people have. Now lets add some tagging in there! Assuming that you have the Tag model imported from tagging, you can simply do this:
def item_categories(self, obj):
return [tag.name for tag in Tag.objects.get_for_object(obj)]
You can test to make sure that your feeds are working by using feedparser
In [1]: import feedparser
In [3]: p = feedparser.parse('http://ericholscher.com/feeds/posts/')
In [4]: p.entries[0].tags
Out[4]:
[{'label': None, 'scheme': None, 'term': u'lawrence'},
{'label': None, 'scheme': None, 'term': u'mediaphormedia'},
{'label': None, 'scheme': None, 'term': u'philosophy'},
{'label': None, 'scheme': None, 'term': u'post-a-day'},
{'label': None, 'scheme': None, 'term': u'ramblings'}]
That's it! Now everyone go do that to their feeds, so that I can harvest your tags and make them useful :)
Posted at 7:09 p.m. on November 22, 2008
Comments: 2
Tags: aggregator , django , post-a-day , projects , tutorial
Introduction to Python/Django testing: Basic Doctests
Building a Django App Server with Chef: Part 4
Practical Django Testing Examples: Views
Welcome to the home of Eric Holscher on the web. I talk about software development, mostly in the realm of Django. I am interested in the real time web, testing, mobile apps, and other things.
Why Read the Docs matters
1 week, 5 days ago (Comments: 7)
Read the Docs Update
9 months, 4 weeks ago (Comments: 2)
Using Reviewboard with Git
1 year ago (Comments: 0)
Read the Docs Updates
1 year ago (Comments: 1)
Handling Django Settings Files
1 year ago (Comments: 12)
Required Reading
1 year, 2 months ago (Comments: 0)
Using Haystack to index non-database content
1 year, 2 months ago (Comments: 4)
Correct commands to check out and update VCS repos
1 year, 2 months ago (Comments: 0)
Site upgrades
1 year, 2 months ago (Comments: 0)
Building a Django App Server with Chef: Part 4
1 year, 2 months ago (Comments: 1)
Setting up Django and mod_wsgi
Building a Django App Server with Chef: Part 1
Screencast: Django Command Extensions
Big list of Django tips (and some python tips too)
Handling Django Settings Files
Lessons Learned From The Dash: Easy Django Deployment
Large Problems in Django, Mostly Solved: Delayed Execution
Building a Django App Server with Chef: Part 2


Comments
1 Alex says...
Yay, blogger does this for me :)
Posted at 2:12 a.m. on November 23, 2008
2 James Tauber says...
Or, if you're using django-atompub, you add something like this:
Posted at 5:40 a.m. on November 23, 2008