You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: django_orm/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The effect should be like this:
19
19
(InteractiveConsole)
20
20
>>>
21
21
22
-
You're know in Django's interactive console. It's just like Python prompt but with some additional Django magic :) You can use all Python commands here too, of course.
22
+
You're now in Django's interactive console. It's just like Python prompt but with some additional Django magic :) You can use all Python commands here too, of course.
23
23
24
24
### All objects
25
25
@@ -64,7 +64,7 @@ Cool! Let's get an instance of the user now:
64
64
65
65
As you can see, we know `get` a `User` with a `username` that equals to 'ola'. Neat! Of course, you have to adjust it to your username.
66
66
67
-
Now we can finally create our first po that:
67
+
Now we can finally create our first post:
68
68
69
69
>>> Post.objects.create(author = user, title = 'Sample title', text = 'Test')
70
70
@@ -79,7 +79,7 @@ You can know have a little fun and add more posts to see how it works. Add 2-3 m
79
79
80
80
### Filter objects
81
81
82
-
Big part of QuerySets is an ability to filter them. Let's say, we want to find all posts that are authored by User ola. We will use it instead of `all` in `Post.objects.all()`. In parentheses we will state what condition(s) needs to be met by a blog post to end up in our queryset. In our situation it is `author` that is equal to `user`. The way to write it in Django is: `author=user`. Now our piece of code looks like that:
82
+
Big part of QuerySets is an ability to filter them. Let's say, we want to find all posts that are authored by User ola. We will use `filter` instead of `all` in `Post.objects.all()`. In parentheses we will state what condition(s) needs to be met by a blog post to end up in our queryset. In our situation it is `author` that is equal to `user`. The way to write it in Django is: `author=user`. Now our piece of code looks like that:
83
83
84
84
>>> Post.objects.filter(author = user)
85
85
[<Post: Sample title>, <Post: Post number 2>, <Post: My 3rd post!>, <Post: 4th title of post>]
0 commit comments