Using Akismet/TypePad AntiSpam with Django's new comments framework

I've just recently started getting lots of spam in my comments. I was originally using a custom OpenID-enabled commenting app that I had written, but decided to switch to the new Django commenting system since it looked interesting. The honeypot doesn't seem to be working though, because spam's still getting through...

Although django-comment-utils provides similar functionality, it hasn't yet been updated to use the new django.contrib.comments. For those of you that are interested, here's how you can use Akismet to protect your blog.

UPDATE: TypePad's AntiSpam service is 100% API compatible with Akismet, so the code below works nicely with it as well.

Sign up at Wordpress to get your API key for Akismet. Paste it into your settings file:

AKISMET_API_KEY = 'your-key-here'

If you'd rather use TypePad's AntiSpam service, paste instead the following:

This code can be tweaked to delete the comment outright if Akismet or TypePad detects that it's spam - connect instead to the comment_will_be_posted signal and return False. The flag is created so that a script can go through and periodically delete all spam.