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 trialChih-Wei Hsu
11,132 Pointsstudent_record ? a new table or a new column??
In the lesson where we create student_record to avoid duplicate usernames in the Student table, and then we use student_record.point to populate points. All of these seem like we've created a new table called student_record in the same database, with a column called student_record that holds the usernames, and a column called point in the student_record table. Is my understanding of student_record correct?? Or is student_record another column in the Student table, and student_record.point is also another column in the Student table??
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsIn the line:
student_record = Student.get(username=student['username'])
student_record
points to a specific saved instance of Student
. student_record.points
is the points
attribute of this instance. After adding the points values, this instance is saved in the Student
table using student.save()
. Said another way, student_record
points to a row in the Student
table. student_record.points
points to the points
column in the Student
table for that row.
Ahmad Faris
1,656 PointsI don't think it's possible using that line of code... because for each Student we have two attributes , namely username and points and using Student.get (student['username']) will throw an error
pawkan kenluecha
26,303 Pointspawkan kenluecha
26,303 PointsHello, Is it possible to use only student['username'] ?
student_record = Student.get(student['username'])
Mike d'julio
941 PointsMike d'julio
941 PointsDoes this means Student.get is pass by reference and not by value?
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsMike d'julio, all Python is βpass by object referenceβ.
Post back if you need more help. Good luck!!!