-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_data_bats.py
31 lines (27 loc) · 1001 Bytes
/
create_data_bats.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
import os
import random
if __name__ == '__main__':
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "modelform.settings")
import django
django.setup()
from app01 import models
names = []
with open('statics/plugins/lol_name', 'r', encoding='utf-8') as f:
for line in f:
names.append(line.strip())
print(len(names))
customer_obj = []
for i in range(0, 90):
obj = models.CustomerInfo(
name=names[i],
contact_type=random.randint(0, 2),
contact=f'21321378{i}',
source=random.randint(0, 5),
referral_from_id=models.CustomerInfo.objects.get(id=1).id,
# consult_courses_id=models.Course.objects.get(id=1).id,
consult_content='什么是'+names[i]+'?',
status=random.randint(0, 2),
# consultant_id=models.UserInfo.objects.get(id=1).id
)
customer_obj.append(obj)
models.CustomerInfo.objects.bulk_create(customer_obj)