From the course: Django Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Solution: Adding likes to notes

Solution: Adding likes to notes

From the course: Django Essential Training

Solution: Adding likes to notes

(upbeat music) - [Instructor] We want to add a new field in the notes model to represent the number of likes a note gets. If we check the documentation, we can see that one option would be to use an IntegerField. They're supposed to represent an integer number, so all seems good, right? However, if we take a deeper look into our options and think about what we want, we can notice that it doesn't make sense to have such a large number available for us. An IntegerField can vary from this really low number to this really high number. This means that every new entry to the database will be huge in number of bytes used, even if that number is only one. We also don't care for negative numbers, as we don't want to support negative numbers of likes. So instead, we could use a PositiveSmallIntegerField. This means that values can range from 0 to about 32000. 32,000 likes seems like a good enough number for now. It'll also restrict our database size, and because the field is marked as positive,…

Contents