Querysets and Django Shell

preview_player
Показать описание
In this tutorial we will learn how to query the database. This step is very important and it may be a bit boring but if you understand how to query I database in Django you basically will never have any issues with django.

We will use the django shell to query the database. We will grab post that we already created, create new post and even delete some post so lets get started.

Let's fire up the django shell.
2. Since our post our tied into the user auth framework we will need to query that database as well so we will need to import the data base
3. Now we want to have access to our post model so we need to import that as well
4. Now we want to have access to the Users post so we have to query the database for them.
5. Now we want to create a new post.
6. Now we have created a new post but we still have to commit it to the database which we will do with a simple onliner.
7. How to do we get the post.
8. Modify objects

9. Order post in alphabetical order
order post in reverse order

10. delete a post
Рекомендации по теме
Комментарии
Автор

THANK YOU. The first few minutes of your video cleared up a question I have wrestled with for the past 4 hours.

matthiasschulz
Автор

I
have 2 weeks looking to understand why do we need queryset . And so far no one has posted or gave me some good answers thank you some much .Great Work

forview
Автор

Thank You Master do you consider recreating the Guide for latest Python3.8 and latest Django ?? cuz alot of things are missing really like, it requesting after Django 2.0 to add on_delete function to the model before migrating it and few more things, that would be great :)

xmrshadyxx
Автор

how do you filter Post's by Author? I mean get all the Posts of certain Author.

okomi