Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Profile(models.Model):
- user = models.OneToOneField(User, unique=True)
- nickname = models.CharField(max_length=32)
- dob = models.DateField(null=False)
- sex = models.BooleanField(null=False)
- def create_random_users(userCount=1000):
- random.seed()
- for i in range(0, userCount):
- sex = random.randint(0, 1)
- name = random.choice(names[sex])
- email = "{0}{1}@mail.com".format(name, i)
- user = soc_models.User.objects.create_user(email, email, password='password')
- user.save()
- userProfile = soc_models.Profile.objects.create()
- userProfile.user = user
- _year = random.randrange(1962, 1995)
- _month = random.randrange(1, 12)
- _day = random.randrange(1, calendar.monthrange(_year, _month)[1])
- userProfile.dob = datetime.datetime(_year, _month, _day)
- userProfile.sex = random.randrange(0, 1)
- userProfile.city = random.randrange(4000000)
- userProfile.country = random.randrange(230)
- userProfile.save()
- userProfile = soc_models.Profile.objects.create()
- userProfile = soc_models.Profile()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement