-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_tasks.py
55 lines (35 loc) · 1.18 KB
/
create_tasks.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
# def main():
# fake: Faker = Faker()
# for i in range(1):
# task = Blog.objects.create(
# name=fake.paragraph(nb_sentences=1),
# description=fake.paragraph(nb_sentences=1),
# image=fake.image_url,
# )
# print(f"Created blog. Title: {task.name}")
# blog_count = Blog.objects.count()
# print(f"There are {blog_count} blogs in the database")
# if __name__ == "__main__":
# import os
# from django.core.wsgi import get_wsgi_application
# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
# application = get_wsgi_application()
# import random
# from faker import Faker
# from blogs_api.models import Blog
# main()
if __name__ == "__main__":
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
application = get_wsgi_application()
from faker import Faker
from blogs_api.models import Blog
fake = Faker()
Faker.seed(2)
for i in range(3):
name = fake.paragraph(nb_sentences=1)
description = fake.paragraph(nb_sentences=2)
# image = fake.image_url(width=250, height=250)
new_blog = Blog(name=name, description=description)
new_blog.save()