Momentum logo
Team 14 Classroom

๐Ÿป Models & Queries ๐Ÿป

Posted on Sep 7th, 2022

๐Ÿ—“๏ธ Todayโ€™s Topics

  • The woes of deployment and what to do about them
  • Django managers, lookups, and querysets
  • Using the Django shell to test out your models and make queries

๐ŸŽฏ Project: Continue Building Habit Tracker

Today your models should be done, so you can begin building out the urls, views, and templates you will need. Before you write the code, plan for what you will need. A good way to do this is to sketch out what your user will see.

There are examples for a lot of what you need to do in the Django Recipes codebase but you will have to adapt them to your Habit Tracker use cases.

๐Ÿ”– Resources

Models

Managers and QuerySets

Queries

You can think of queries as talking to the database. To support all our CRUD actions, we need to be able to create, read, update, and delete objects from the database. Django has a built-in library (the Django ORM) that lets us do all that.

๐ŸŒŸ EXTRA/TMI

Links in this section are really more information than you need right now, but itโ€™s relevant and interesting. Things included here are good to know but ok to save for later.

  • What is SQL?
  • SQL Basics: Learn X in Y minutes -> this is a helpful reference for SQL syntax when you run into it. You do not need to write SQL for Django because the Django ORM does it for you, and it does it well. The Django docs often illustrate queries made by the ORM using SQL syntax, however, and you will find it helpful in your job to know the basics.

๐Ÿฆ‰ Code & Notes

Back to home