Created
November 8, 2018 10:01
-
-
Save vubon/a42ab9224511d0b888ac19fc513ed326 to your computer and use it in GitHub Desktop.
Generate Excel Sheet of Django user
This file contains hidden or 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
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