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 trialDmitry Karamin
10,099 Pointsupdate() method
i'm a little confused about question in quiz "You can use .update() on a single model instance." i answered True but failed. To tell the truth i didn't get the question and didn't find answer in Django docs. Could you please explain the meaning of this question.
3 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsThe question is referring to the QuerySet method .update() which runs on a QuerySet and does not call a model's .save()
method so is not effective on a single instance. More information available at updating multiple objects at once.
For the quiz question, the difference is between using .update
on a QuerySet which may have many, one, or no objects in the set [allowed] and trying to call the .update
method of a specific instance which does not exist [not allowed].
Dmitry Karamin
10,099 PointsThe question is not about efficiency but about possibility to use. I Can use update() for single and multiple instances. So to my mind question is not quite correct.
Chris Freeman
Treehouse Moderator 68,454 PointsThere isn't an update
method on an instance. See expanded answer above.
Dmitry Karamin
10,099 PointsOk i got it thanks