Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import os
- #import copy
- #import sys
- #import warnings
- #from collections import OrderedDict, deque
- #from django.conf import settings
- #from django.core import exceptions
- #from django.db import (
- # DJANGO_VERSION_PICKLE_KEY, IntegrityError, connections, router,
- # transaction,
- #)
- #from django.core.management.base import BaseCommand
- from shop.models import producer
- from shop.models import product
- from shop.models import category
- from shop.models import order
- from django.contrib.auth.models import User
- import random
- import string
- def g_username():
- name = ""
- for i in range(random.randint(2, 16)):
- name += random.choice("qwertyuiopasdfghjklzxcvbnm1234567890")
- return name
- def g_email():
- mail = ""
- for i in range(random.randint(2, 16)):
- mail += random.choice("qwertyuiopasdfghjklzxcvbnm1234567890")
- mail += random.choice(["@yandex.ru", "@mail.ru", "@gmail.com", "@yahoo.com"])
- return mail
- def g_password():
- pas=""
- for i in range(random.randint(8, 20)):
- pas += random.choice("1234567890qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM")
- return pas
- def g_name():
- f = open('Random/namesf.txt')
- names = f.readlines()
- name = random.choice(names).strip()
- f.close()
- return name
- def g_surname():
- f = open('Random/surnames.txt')
- surnames = f.readlines()
- surname = random.choice(surnames).strip()
- return surname
- def g_category():
- f = open('Random/categories.txt')
- categories = f.readlines()
- category = random.choice(categories).strip()
- return category
- def g_price():
- price = random.randint(0, 100000)
- return price
- def description():
- f = open('Random/descriptions.txt')
- descriptions = f.readlines()
- description = random.choice(countries).strip()
- return description
- def g_country():
- f = open('Random/countries.txt')
- countries = f.readlines()
- country = random.choice(countries).strip()
- return country
- def g_user():
- username = g_username()
- email = g_email()
- password = g_password()
- usr = User(username=username, email=email, password=password)
- usr.first_name = g_name()
- usr.last_name = surname()
- return usr
- def g_users(n=10000):
- users = []
- for i in range(n):
- users.append(g_user())
- User.objects.bulk_create(users)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement