Advertisement
Guest User

Untitled

a guest
Apr 5th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.41 KB | None | 0 0
  1. #import os
  2. #import copy
  3. #import sys
  4. #import warnings
  5. #from collections import OrderedDict, deque
  6.  
  7. #from django.conf import settings
  8. #from django.core import exceptions
  9. #from django.db import (
  10. #    DJANGO_VERSION_PICKLE_KEY, IntegrityError, connections, router,
  11. #    transaction,
  12. #)
  13. #from django.core.management.base import BaseCommand
  14. from shop.models import producer
  15. from shop.models import product
  16. from shop.models import category
  17. from shop.models import order
  18. from django.contrib.auth.models import User
  19. import random
  20. import string
  21. def g_username():
  22.     name = ""
  23.     for i in range(random.randint(2, 16)):
  24.         name += random.choice("qwertyuiopasdfghjklzxcvbnm1234567890")
  25.     return name
  26.  
  27. def  g_email():
  28.     mail = ""
  29.     for i in range(random.randint(2, 16)):
  30.         mail += random.choice("qwertyuiopasdfghjklzxcvbnm1234567890")
  31.         mail += random.choice(["@yandex.ru", "@mail.ru", "@gmail.com", "@yahoo.com"])
  32.     return mail
  33.  
  34. def g_password():
  35.     pas=""
  36.     for i in range(random.randint(8, 20)):
  37.         pas += random.choice("1234567890qwertyuiopasdfghjklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM")
  38.         return pas
  39.  
  40. def g_name():
  41.     f = open('Random/namesf.txt')
  42.     names = f.readlines()
  43.     name = random.choice(names).strip()
  44.     f.close()
  45.     return name
  46.  
  47.  
  48. def g_surname():
  49.     f = open('Random/surnames.txt')
  50.     surnames = f.readlines()
  51.     surname = random.choice(surnames).strip()
  52.     return surname
  53.  
  54. def g_category():
  55.     f = open('Random/categories.txt')
  56.     categories = f.readlines()
  57.     category = random.choice(categories).strip()
  58.     return category
  59.  
  60. def g_price():
  61.     price = random.randint(0, 100000)
  62.     return price
  63.  
  64. def description():
  65.     f = open('Random/descriptions.txt')
  66.     descriptions = f.readlines()
  67.     description = random.choice(countries).strip()
  68.     return description
  69.  
  70. def g_country():
  71.     f = open('Random/countries.txt')
  72.     countries = f.readlines()
  73.     country = random.choice(countries).strip()
  74.     return country
  75.  
  76. def g_user():
  77.     username = g_username()
  78.     email = g_email()
  79.     password = g_password()
  80.     usr = User(username=username, email=email, password=password)
  81.     usr.first_name = g_name()
  82.     usr.last_name = surname()
  83.     return usr
  84.  
  85.  
  86. def g_users(n=10000):
  87.     users = []
  88.     for i in range(n):
  89.         users.append(g_user())
  90.     User.objects.bulk_create(users)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement