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
@@ -125,15 +126,15 @@ A big part of QuerySets is the ability to filter them. Let's say we want to find
125
126
{% filename %}command-line{% endfilename %}
126
127
```python
127
128
>>> Post.objects.filter(author=me)
128
-
[<Post: Sample title>, <Post: Post number 2>, <Post: My 3rd post!>, <Post: 4th title of post>]
129
+
<QuerySet [<Post: Sample title>, <Post: Post number 2>, <Post: My 3rd post!>, <Post: 4th title of post>]>
129
130
```
130
131
131
132
Or maybe we want to see all the posts that contain the word 'title' in the `title` field?
132
133
133
134
{% filename %}command-line{% endfilename %}
134
135
```python
135
136
>>> Post.objects.filter(title__contains='title')
136
-
[<Post: Sample title>, <Post: 4th title of post>]
137
+
<QuerySet [<Post: Sample title>, <Post: 4th title of post>]>
137
138
```
138
139
139
140
> **Note** There are two underscore characters (`_`) between `title` and `contains`. Django's ORM uses this rule to separate field names ("title") and operations or filters ("contains"). If you use only one underscore, you'll get an error like "FieldError: Cannot resolve keyword title_contains".
@@ -144,7 +145,7 @@ You can also get a list of all published posts. We do this by filtering all the
Unfortunately, the post we added from the Python console is not published yet. But we can change that! First get an instance of a post we want to publish:
@@ -166,7 +167,7 @@ Now try to get list of published posts again (press the up arrow key three times
Copy file name to clipboardExpand all lines: en/django_templates/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,7 @@ It works! But we want the posts to be displayed like the static posts we created
64
64
65
65

66
66
67
-
Have you noticed that we used a slightly different notation this time (`{{ post.title }}` or `{{ post.text }})`? We are accessing data in each of the fields defined in our `Post` model. Also, the `|linebreaksbr` is piping the posts' text through a filter to convert line-breaks into paragraphs.
67
+
Have you noticed that we used a slightly different notation this time (`{{ post.title }}` or `{{ post.text }}`)? We are accessing data in each of the fields defined in our `Post` model. Also, the `|linebreaksbr` is piping the posts' text through a filter to convert line-breaks into paragraphs.
0 commit comments