-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinsert_sample_db_data.py
executable file
·44 lines (37 loc) · 1.68 KB
/
insert_sample_db_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import os
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "accountdemo.settings")
snacks = ('Chips', 'Candy', 'Coke', 'Ice cream')
first_names = ('Jeffrey', 'Chris', 'Jeff', 'John')
last_names = ('Tucker', 'Fisher', 'Tucker', 'Doe')
users = (
{'user': 'Hercules', 'email': 'nobody@example.com'},
{'user': 'Motoko', 'email': 'theman@example.com'},
{'user': 'Azusa', 'email': 'lol@example.com'},
{'user': 'mio32', 'email': '1337@example.com'},
{'user': 'RiTsU_92', 'email': 'pro@example.com'},
{'user': '1337', 'email': 'vim_god@example.com'},
{'user': 'L33T', 'email': 'linux@example.com'},
{'user': 'King', 'email': 'hjkl@example.com'},
{'user': 'LinuxHero', 'email': 'bitcoin@example.com'},
{'user': 'VimLover', 'email': 'litecoin@example.com'},
{'user': 'vim', 'email': 'altcoin@example.com'},
)
def create_user(username, email, password):
user = UserenaSignup.objects.create_user(username, email, password, True, False)
user.first_name = first_names[random.randint(0, len(first_names) - 1)]
user.last_name = last_names[random.randint(0, len(last_names) - 1)]
user.save()
profile = user.profile
profile.favourite_snack = snacks[random.randint(0, len(snacks) - 1)]
profile.save()
import random
from userena.models import UserenaSignup
for user in users:
create_user(user['user'], user['email'], 'lol')
from django.contrib.sites.models import Site
site = Site.objects.get(pk=1)
site.domain = '127.0.0.1:8000'
site.name = 'Account demo'
site.save()