Skip to content

Instantly share code, notes, and snippets.

@jice-lavocat
Created January 17, 2017 15:28
Show Gist options
  • Save jice-lavocat/3ddfa7ceee69520887e70559f587047c to your computer and use it in GitHub Desktop.
Save jice-lavocat/3ddfa7ceee69520887e70559f587047c to your computer and use it in GitHub Desktop.
Django quick CSV export of user emails
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)
@jice-lavocat
Copy link
Author

Will create a email.csv file with all your users emails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment