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 trial
Connor James
5,380 PointsAccessing and saving an attribute from one model into another
I have a class, Cereal, that Foreign Keys off to another class, Groceries. I want to add an attribute, cereal_name, to the Groceries class by accessing the attribute, name, in the Cereal class. Any Ideas?
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsThe reverse relation is automatically added. You can access all of the cereal pointing to the Groceries model using grocery.cereal_set See following relationships backward docs.
Connor James
5,380 PointsConnor James
5,380 PointsThanks for the feedback! I will try it out.