From the course: Django Essential Training
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
</> Code challenge: Adding likes to notes
From the course: Django Essential Training
</> Code challenge: Adding likes to notes
(upbeat electronic music) - [Instructor] In this chapter, you'll learn how to create a new model and update your database for the schema you defined in your model. However, as you've seen, we can never know everything we'll need in advance, so we're going to add a new feature to our notes model. The challenge is to add a new field to the notes model where you can store the number of likes a specific note have. Once you do that, you should change the database to be able to store this new parameter. To solve this challenge, you'll need a couple of things. You'll need to add a new field to the model class notes. You'll also need to figure out which type of field you should add so you can store the number of likes. You're also going to need to figure out how to populate notes that already exist because this is a new field, and we already have notes that have no likes. Finally, you need to figure out how to apply those changes to the database so we can actually store the number of likes. I…
Contents
-
-
-
-
-
(Locked)
Introduction to ORMs1m 21s
-
(Locked)
Creating your first model3m 15s
-
Using admin for data creation and manipulation3m
-
(Locked)
Using Django shell for creating and querying data4m 42s
-
(Locked)
</> Code challenge: Adding likes to notes1m 20s
-
(Locked)
Solution: Adding likes to notes3m 26s
-
(Locked)
-
-
-
-
-
-
-