Last active
December 9, 2016 10:09
-
-
Save wowkin2/b014e6737b1fd7219902f529926855ed to your computer and use it in GitHub Desktop.
Update django username after AutoFixture to human readable format using Faker
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
""" | |
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