First time here? Check out the FAQ!
2

SQL command to delete all users with karma 1

I have more than 2000 user accounts which need to be deleted. In the /admin/ page I cannot filter these users out.

Is there perhaps an SQL command that allows me to delete all the users with karma 1 (or users without any posts).

To be sure -- because I am not very technical -- what is an SQL to backup the database first. And what would be to a SQL command that lists all the users satisfying my criteria. Just want to be sure that I don't delete all users.

Thanks :)

kristof's avatar
51
kristof
asked 2016-03-05 12:47:09 -0500
Evgeny's avatar
13.2k
Evgeny
updated 2016-06-15 06:19:08 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

-1

You might log in to the django shell:

python manage.py shell

Then type :

from askbot.models import User
uu = User.objects.filter(askbot_profile__reputation=1) #or (reputation=1) for versions < 0.8
for u in uu:
    try:
        u.delete()
    except:
        pass
Evgeny's avatar
13.2k
Evgeny
answered 2016-03-09 05:54:15 -0500
edit flag offensive 0 remove flag delete link

Comments

can it be done with UI?

Andy's avatar Andy (2016-03-09 21:44:58 -0500) edit
add a comment see more comments