-
Notifications
You must be signed in to change notification settings - Fork 0
/
initial_data.py
33 lines (27 loc) · 1.05 KB
/
initial_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
# coding: utf-8
from theapp.models import *
def main():
usernames = ['jack', 'ginny', 'ralph']
passwords = ['password'] * 5
locations = ['Delhi', 'Noida', 'Bangalore']
emails = ['[email protected]', '[email protected]',
for loc in locations:
City.objects.create(name=loc)
cities = City.objects.all()
for un, pwd, email, loc in zip(usernames, passwords, emails, cities):
user = User(username=un, location=loc, email=email)
user.set_password(pwd)
user.save()
at1_group = Group.objects.create(name='AdminType1')
at2_group = Group.objects.create(name='AdminType2')
admin_L1 = User.objects.create_superuser(
username='admin_l1', email='[email protected]',
password='pass', location=City.objects.last())
admin_L2 = User.objects.create_superuser(
username='admin_l2', email='[email protected]',
password='pass', location=City.objects.last())
admin_L1.groups.add(at1_group)
admin_L2.groups.add(at2_group)
if __name__ == '__main__':
main()