-
Notifications
You must be signed in to change notification settings - Fork 3
/
dummy_data.py
63 lines (56 loc) · 1.83 KB
/
dummy_data.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os, django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
django.setup()
from faker import Faker
import random
from django.utils import timezone
from jobs.models import Company , Category , Job
def add_companies(n):
images=['1.png','2.png']
fake=Faker()
for n in range(n):
Company.objects.create(
name=fake.name(),
logo=f"company/{images[random.randint(0,1)]}",
presentation=fake.text(),
website=fake.domain_name(),
email=fake.ascii_email(),
)
print(f'{n} Companies was created successfully')
def add_categories(n):
images=['1.png','2.png']
fake=Faker()
for n in range(n):
Category.objects.create(
name=fake.name(),
image=f"categorys/{images[random.randint(0,1)]}",
job_count=random.randint(0,1),
)
print(f'{n} Categories was created successfully')
def add_jobs(n):
fake=Faker()
categories = Category.objects.all()
companies = Company.objects.all()
natures=['Full Time','Part Time','Remote','Freelance']
for n in range(n):
category = random.choice(categories)
agency = random.choice(companies)
current_date = timezone.now()
Job.objects.create(
title=fake.name(),
category=category,
agency=agency,
location=fake.city(),
salary=random.randint(500,90000),
created_at=current_date,
vacancy=random.randint(0,10),
job_nature=natures[random.randint(0,3)],
application_date=fake.date_time(),
description=fake.text(),
knowledge_requirements=fake.text(),
education_experience=fake.text(),
)
print(f'{n} Jobs was created successfully')
add_companies()
add_categories()
add_jobs(0)