posted on Feb 21, 2009 at 11:18 a.m. EST in
import os
import time
import optparse
import datetime
def delete_spam_comments(verbose=False):
from django.contrib.comments.models import Comment
spam_comments = Comment.objects.filter(is_public=False)
deleted_count = spam_comments.count()
for Comment in spam_comments:
Comment.delete()
if spam_comments:
print "Removed %s spam comments from database" % deleted_count
if __name__ == '__main__':
parser = optparse.OptionParser()
parser.add_option('--settings')
parser.add_option('-v', '--verbose', action="store_true")
options, args = parser.parse_args()
if options.settings:
os.environ["DJANGO_SETTINGS_MODULE"] = options.settings
delete_spam_comments(options.verbose)
python
1
import os
import time
import optparse
import datetime
def delete_spam_comments ( verbose = False ):
from django.contrib.comments.models import Comment
spam_comments = Comment . objects . filter ( is_public = False )
deleted_count = spam_comments . count ()
for Comment in spam_comments :
Comment . delete ()
if spam_comments :
print "Removed %s spam comments from database" % deleted_count
if __name__ == '__main__' :
parser = optparse . OptionParser ()
parser . add_option ( '--settings' )
parser . add_option ( '-v' , '--verbose' , action = "store_true" )
options , args = parser . parse_args ()
if options . settings :
os . environ [ "DJANGO_SETTINGS_MODULE" ] = options . settings
delete_spam_comments ( options . verbose )
copy
|
embed
Hey there! I see you're running Internet Explorer 6.
That's neat. This reminds me of my grandpa. He had this old car that he kept having to fix. He spent so much money on it that he didn't want to get rid of it (even when it stopped running).
You guys should hang out.
Here's a free sports car from Snipt.
0 Comments