Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from shop.models import User
- from shop.models import ManufacturerCountry
- from shop.models import producer
- from shop.models import product
- from shop.models import category
- from shop.models import order
- from django.core.files import File
- from datetime import datetime
- import random
- def g_username():
- s = ""
- for i in range(random.randint(6, 18)):
- s += random.choice("qwertyuiopasdfghjklzcvbxnm1234567890_-QWERTYUIOPASDFGHJKLZXCVBNM")
- return s
- def g_email():
- s = ""
- for i in range(random.randint(13, 20)):
- s += random.choice("qwertyuiopasdfghjklzcvbxnm1234567890")
- s += random.choice(["@gmail.com", "@mail.ru", "@yandex.ru", "@yahoo.com"])
- return s
- def g_password():
- s = ""
- for i in range(random.randint(20, 30)):
- s += random.choice("qwertyuiopasdfghjklzcvbxnm1234567890 QWERTYUIOPASDFGHJKLZXCVBNM_-")
- return s
- def g_name():
- f = open('Random/names.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(names).strip()
- f.close()
- return name
- def g_ManufacturerCountry():
- f = open('Random/countries.txt')
- countries = f.readlines()
- country = random.choice(countries).strip()
- f.close()
- return country
- def g_category():
- f = open('Random/categories.txt')
- categories = f.readlines()
- category = random.choice(categories).strip()
- f.close()
- return category
- def g_producer():
- f = open('Random/producers.txt')
- producers = f.readlines()
- producer = random.choice(producers).strip()
- f.close()
- return producer
- def g_price():
- price = random.randint(1, 10000)
- return price
- def g_product():
- f = open('Random/products.txt')
- products = f.readlines()
- product = random.choice(countries).strip()
- f.close()
- return product(name = random.choice(products).strip(), price = g_price(), producer = g_producer(), manufacturerCountry = g_countyry())
- def g_order():
- order_object = order()
- order_object.save()
- i = random.randint(1, 10)
- order_object.products.add(i)
- return order(customer = g_user())
- def g_products(n):
- products = []
- for i in range(n):
- products.append(g_product())
- product.objects.bulk_create(products)
- g_products(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement