Skip to content

Instantly share code, notes, and snippets.

@vubon
Created November 8, 2018 10:01
Show Gist options
  • Save vubon/a42ab9224511d0b888ac19fc513ed326 to your computer and use it in GitHub Desktop.
Save vubon/a42ab9224511d0b888ac19fc513ed326 to your computer and use it in GitHub Desktop.
Generate Excel Sheet of Django user
import csv
from django.contrib.auth.models import User
def run():
with open("users.xls", "w", newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['Username', 'Full Name', 'Email address'])
users = User.objects.filter(is_active=True, is_staff=False)
for user in users:
writer.writerow([user.username, user.first_name + user.last_name, user.email])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment