Skip to content

Instantly share code, notes, and snippets.

@chris-erickson
Created November 23, 2016 15:01
Show Gist options
  • Save chris-erickson/ade9e74b56333c91d780eb0f0082a2d1 to your computer and use it in GitHub Desktop.
Save chris-erickson/ade9e74b56333c91d780eb0f0082a2d1 to your computer and use it in GitHub Desktop.
A really hacky way to load a bunch of users through the shell instead of writing something more complicated.
# This is just a really hacky way to load a bunch of users through the shell instead of writing something more complicated.
# Intructions: Paste it in line by line!
names = [
["FirstName", "LastName", "something@email.com", "username", "a-password-here"],
["FirstName", "LastName", "something@email.com", "username", "a-password-here"],
]
FNAME = 0
LNAME = 1
EMAIL = 2
UNAME = 3
PASSW = 4
GROUP_PK = 4
group = Group.objects.get(pk=GROUP_PK)
for n in names:
u = User.objects.create_user(n[UNAME], email=n[EMAIL], password=n[PASSW])
u.first_name = n[FNAME]
u.last_name = n[LNAME]
u.is_staff = True
u.save()
u.groups.add(group)
print(u.pk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment