random
string
django.db models
(models.Model):
name = models.CharField(=)
age = models.IntegerField()
sex = models.IntegerField(=(()())=)
card_no = models.CharField(=)
(num):
(raw_itelength):
.join(random.choices(raw_ite=length))
obj_li = []
_ (num):
obj_li.append(Student(
=random_str(string.random.randint())=random.randint()=random.choice([])=random_str(string.digits)
))
Student.objects.bulk_create(obj_li)
>>> Student.insert_test_data(303)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "D:\python_VirtualEnv\paginator_study\paginator_app\models.py", line 18, in insert_test_data
name=random_str(string.ascii_lowercase,random.randint(6,10)),
File "D:\python_VirtualEnv\paginator_study\paginator_app\models.py", line 14, in random_str
return ''.join(random.choices(raw_ite,k=length))
NameError: name 'join' is not defined
>>>
老师:为什么 ‘name 'join' is not defined’