diff options
author | Dan McGee <dpmcgee@gmail.com> | 2011-06-19 11:36:23 -0500 |
---|---|---|
committer | Dan McGee <dpmcgee@gmail.com> | 2011-06-19 11:36:23 -0500 |
commit | dbd212f3114f17b5b02c3428e0acd50215bf5c8d (patch) | |
tree | e546d87d08eb070716418e46535940016e862d05 | |
parent | 41f4914f577b3cfe12d463ee95b91d5217781da0 (diff) | |
download | website-dbd212f3114f17b5b02c3428e0acd50215bf5c8d.tar.gz website-dbd212f3114f17b5b02c3428e0acd50215bf5c8d.zip |
Use exists() instead of count()
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
-rw-r--r-- | mycomments/signals.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mycomments/signals.py b/mycomments/signals.py index 0436ab9..774bfcd 100644 --- a/mycomments/signals.py +++ b/mycomments/signals.py @@ -53,9 +53,9 @@ def check_spam_comment(sender, **kwargs): # if the comment has a logged-in user, we don't to check it if comment.user: return True - ip_ct = BannedIP.objects.filter(ip_address=comment.ip_address).count() - un_ct = BannedUserName.objects.filter(user_name=comment.user_name).count() - if ip_ct > 0 or un_ct > 0: + ip_exists = BannedIP.objects.filter(ip_address=comment.ip_address).exists() + un_exists = BannedUserName.objects.filter(user_name=comment.user_name).exists() + if ip_exists or un_exists: # If we found the IP or name in the ban table, this comment is bogus. # Returning 'False' will throw a 403 and comment is discarded. return False |