Join Caleb Smith for an in-depth discussion in this video Querying data with the Django ORM, part of Up and Running with Python and Django.
- I've left the server running from the previous video and…added a few items in the admin.…You can use the same data as me, or use your own.…For the work we'll do in this video, you'll want at least…one item with an amount of zero, and at least…two items with an amount of ten.…Now we'll open a terminal window or use the existing…one that's running our run server and hit ctrl+c.…You'll need to navigate to the folder where manage.py…is and you're running the project.…For me, this will be in the exercise files.…From here you'll type "python manage.py shell"…This will open an interactive python…shell with Django initialized.…
Now to clear the screen and make it easier to see, I'll…type ctrl+l. Now we're in a python shell, and I'll…import our item model from the inventory.models module.…From inventory.models import item.…Now that we've imported the item model, I can use it…to make queries. Let's begin with the .all method.…For this, I'll type item.objects.all…This returns a query set of all instances of this model.…
- Creating a new Django project
- Defining Django models and fields
- Querying data with the Django ORM
- Building views and templates