Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 54 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions project/categories/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import factory

from .models import Category


class CategoryFactory(factory.django.DjangoModelFactory):
class Meta:
model = Category

name = factory.Faker("name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ´name´factory is used to generate names or people. Let's use Faker factory ´lorem´ here, since it is more like a keyword.

https://faker.readthedocs.io/en/master/providers/faker.providers.lorem.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = factory.Faker("name")
name = factory.Faker("lorem")



categories = CategoryFactory.create_batch(10)
for category in categories:
print(category.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to add these lines, since we will want to generate the fake content via a manual command.

Suggested change
categories = CategoryFactory.create_batch(10)
for category in categories:
print(category.name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @brylie. I will work on it. If you get time, please you can also review the other PR, I mentioned. Thanks.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ipython = "^8.5.0"
django-debug-toolbar = "^3.7.0"
django-linear-migrations = "^2.5.1"
pre-commit = "^2.20.0"
factory-boy = "^3.2.1"

[tool.isort]
profile = "black"
Expand Down