-
Notifications
You must be signed in to change notification settings - Fork 351
Added a factory file for the Category Model #1496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0f02e6f
017a49c
b1d54c0
40a43d1
6630449
a2b5eeb
762f44a
1345209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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") | ||||||||
|
|
||||||||
|
|
||||||||
| categories = CategoryFactory.create_batch(10) | ||||||||
| for category in categories: | ||||||||
| print(category.name) | ||||||||
|
||||||||
| categories = CategoryFactory.create_batch(10) | |
| for category in categories: | |
| print(category.name) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.