Skip to content

Instantly share code, notes, and snippets.

@wowkin2
Last active December 9, 2016 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wowkin2/b014e6737b1fd7219902f529926855ed to your computer and use it in GitHub Desktop.
Save wowkin2/b014e6737b1fd7219902f529926855ed to your computer and use it in GitHub Desktop.
Update django username after AutoFixture to human readable format using Faker
"""
To update users to human-readable form
"""
from django.contrib.auth.models import User
from faker import Faker
def update_users():
""" Update username after AutoFixture to human readable
"""
fake = Faker()
fake.seed()
users = User.objects.all()
for user in users:
first_name = fake.first_name()
last_name = fake.last_name()
user.first_name = first_name
user.last_name = last_name
user.username = str(first_name[0] + last_name).lower()
user.email = ('%s.%s@ayasdi.com' % (first_name, last_name)).lower()
user.save()
if __name__ == '__main__':
update_users()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment