Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSimon Amz
4,606 PointsCan't create review as bulk
Hi there,
I cannot succeed to create some data in bulk but when I test it in the shell it works perfectly.
Here is attached my code.
Thanks for your response
from . import models
def fix_25():
Review.objects.bulk_create([
Review(product=1, rating=2),
Review(product=1, rating=3),
Review(product=1, rating=5)
])
2 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsYou are really close. Two fixes needed:
- Since the import was for
models
, the Review objects need to be referred to asmodels.Review
- The parameter should be
product_id
instead ofproduct
Post back if you have more questions. Good luck!!
Simon Amz
4,606 PointsHi Chris got it, thanks.
Now, what is the difference between:
- product_id
- product.id
- product_pk
- product.pk
thanks for the explanation, it's not very clear on the video.