Last active
June 14, 2024 07:42
-
-
Save ianfitzpatrick/a0df2c5e288785d987ac2add4c187651 to your computer and use it in GitHub Desktop.
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
import csv | |
from django.contrib.auth.models import User | |
fields = ['username', 'first_name', 'last_name', 'is_active', 'email', 'id', 'last_login', 'date_joined'] | |
users = User.objects.filter(is_active=True, facebookprofile__isnull=False, child_of__isnull=True) | |
users = users.values_list(*fields) | |
user_count = users.count() | |
with open('users.csv', 'w', newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
writer.writerow(fields) | |
for idx, user in enumerate(users): | |
writer.writerow(user) | |
print(f'{idx}/{user_count}', end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment