Skip to content
Browse files

Fixed #2678 -- Moved the list of profanities for the hasNoProfanities…

… validator

into global_settings. Patch from Matt Croydon.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 4f63ce5 commit b46a093c4598385b3bc7fb5803ebe7bb0677fdd4 @malcolmt malcolmt committed
4 django/conf/
@@ -272,6 +272,10 @@
+# The profanities that will trigger a validation error in the
+# 'hasNoProfanities' validator. All of these should be in lower-case.
+PROFANITIES_LIST = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit']
# The group ID that designates which users are banned.
# Set to None if you're not using it.
3  django/core/
@@ -227,9 +227,8 @@ def hasNoProfanities(field_data, all_data):
catch 'motherfucker' as well. Raises a ValidationError such as:
Watch your mouth! The words "f--k" and "s--t" are not allowed here.
- bad_words = ['asshat', 'asshead', 'asshole', 'cunt', 'fuck', 'gook', 'nigger', 'shit'] # all in lower case
field_data = field_data.lower() # normalize
- words_seen = [w for w in bad_words if field_data.find(w) > -1]
+ words_seen = [w for w in settings.PROFANITIES_LIST if field_data.find(w) > -1]
if words_seen:
from django.utils.text import get_text_list
plural = len(words_seen) > 1
6 docs/settings.txt
@@ -596,6 +596,12 @@ Whether to prepend the "www." subdomain to URLs that don't have it. This is
only used if ``CommonMiddleware`` is installed (see the `middleware docs`_).
See also ``APPEND_SLASH``.
+A list of profanities that will trigger a validation error when the
+``hasNoProfanities`` validator is called.

0 comments on commit b46a093

Please sign in to comment.
Something went wrong with that request. Please try again.