示例#1
0
 def handle(self, *args, **kwargs):
     total = kwargs['total']
     for i in range(total):
         user = RandomUser()
         User.objects.create_user(username=RandomUser.get_username(user), first_name=RandomUser.get_first_name(user),
                                  last_name=RandomUser.get_last_name(user), email=RandomUser.get_email(user),
                                  password=RandomUser.get_password(user),
                                  date_joined=RandomUser.get_registered(user))
示例#2
0
 def create_random(cls):
     user = RandomUser()
     name = user.get_username()
     return Team(name=name, enabled=True)
示例#3
0
文件: bot.py 项目: JohnBox/StarNavi
import requests
import json
import random
from randomuser import RandomUser

config = json.load(open('config.json'))

api = lambda url: f'http://localhost:8000/api/{url}'

user_count = 0
users = []
posts = []
while user_count != config['number_of_users']:
    user = RandomUser()
    user_data = {
        'username': user.get_username(),
        'password': user.get_password(),
        'email': user.get_email(),
        'first_name': user.get_first_name(),
        'last_name': user.get_last_name()
    }
    resp = requests.post(api('users/'), json=user_data)
    if resp.status_code == 201:
        user_count += 1
        user_data['id'] = resp.json().get('id')
    else:
        continue
    print('USER CREATED')
    token_data = {'username': user_data['username'], 'password': user_data['password']}
    resp = requests.post(api('token/'), json=token_data)
    if resp.status_code == 200:
示例#4
0
first = []
last = []
username = []
phone = []
gender = []
email = []

N = 50

for i in range(N):
    user = RandomUser()

    first.append(user.get_first_name())
    last.append(user.get_last_name())
    username.append(user.get_username())
    phone.append(user.get_phone())
    gender.append(user.get_gender())
    email.append(user.get_email())

df = pd.DataFrame(columns=[
    'First_Name', 'Last_Name', 'Gender', 'Username', 'Phone', 'Email'
])
df['First_Name'] = first
df['Last_Name'] = last
df['Gender'] = gender
df['Username'] = username
df['Phone'] = phone
df['Email'] = email

df