forked from Chethan-b13/Bloom_Bids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
populate_script.py
35 lines (31 loc) · 1.19 KB
/
populate_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from unicodedata import name
from core.models import *
from django.utils import timezone
from django.contrib.auth.models import User
from faker import Faker
import random
import os
import django
def create_post(N):
fake = Faker()
Flowers = ['Jasmine', 'Rose',
'Areca catechu(pakku flower)', 'Avarampoo (Senna flower)',
'kakada', 'Crossandra(Kangabaram)', 'Tulsi String', 'Yellow Chrysanthemum']
for _ in range(N):
category = random.randint(1, 4)
flower_name = random.choice(Flowers)
price = random.randint(250, 700)
discount_price = price - random.randint(25, 100)
is_auctioned = False
description = fake.text()
Posts.objects.create(flower_name=flower_name,
price=price, discount_price=discount_price,
category=Category.objects.get(
id=category),
description=description,
is_auctioned=is_auctioned
)
if __name__ == "__main__":
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'collegeblog.settings')
django.setup()
create_post(5)