Django Comments Spam
January 2, 2011
I've suffered over Christmas from someone spamming this blog's comments. The comments functionality was done using Django's contrib comments and so isn't easy to change.
I'll probably have to rewrite it as some point so it's not so standard, or to add a simple sum in, but for now I needed a way to stop a particular message being posted.
Each of the spams I was getting a lot of featured the same uncommon word in the body of the comment. It was therefore possible to just add that word to Django's profanity list. The contrib comments functionality refuses posts where the comment contains one of the words in this list.
Here's the settings that needed changing, with the words themselves changed to protect the guilty.
COMMENTS_ALLOW_PROFANITIES=False PROFANITIES_LIST = ('a', 'a', 'a', 'c', 'f', 'g', 'n', 's', 't')
You can find the existing default PROFANITIES_LIST
in django/conf/global_settings.py
. COMMENTS_ALLOW_PROFANITIES
defaults to False.