Created
January 17, 2017 15:28
-
-
Save jice-lavocat/3ddfa7ceee69520887e70559f587047c to your computer and use it in GitHub Desktop.
Django quick CSV export of user emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
import csv | |
writer = csv.writer(open("email.csv", 'w')) | |
qs = User.objects.all().values("email") | |
for obj in qs: | |
row = [] | |
if type(obj['email']) == unicode: | |
email = obj['email'].encode("utf-8") | |
row.append(email) | |
writer.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will create a email.csv file with all your users emails