-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Use of itertools.count to generate record ids in Recipe #123
Comments
Hi @formacube, thanks for your issue. Did you tried to use sequences instead? You can use it as: from model_bakery.recipes import seq
fake_play = Recipe(Play, puzzle_id=seq(1)) This is the correct way to bakery's recipes with iterables. |
you are right ! I only used Thanks a lot Berinhard |
You're welcome! I'm glad model bakery is being useful for you =) |
model bakery is extremely useful ! for the record: however, I receive now the following error when using seq:
My goal is to fill-in the id number corresponding to a foreign key:
Have you ever performed that ? |
Hi Bernardo, By applying your proposition, I found out it is not working. |
@formacube I'm preparing myself for Brazil's PyCon (we call it Python Brasil) which will begin next monday. Because of that I'm with a lot of stuff in my plate now, but as soon as things calm down I'll revisit this issue. Probably this will happen during python brasil's sprints days. |
Anyway, I reopened this issue so I won't forget to read it again =) |
Thanks a lot, and have a nice event |
Hi,
itertools.count
does not seem to be working in recipe or in a direct make statementwhen I declare:
or
fake_play = Recipe(Play, puzzle_id=it.count(start=1))
I expected puzzle_id to take incremental values 1,2,3, ... 7
Instead, I receive an error message:
I have tried different things but I don't really see what is happening as
itertools.cycle
is working well.There seem to be nothing on the internet about it, not on the documentation. So I would assume it normally works
Could you help me out?
Versions
Python:Python 3.7.4
Django: 2.2.7
Model Bakery:1.0.2
The text was updated successfully, but these errors were encountered: