Skip to content

Commit fe97bb0

Browse files
committed
add a short section about chaining querysets
1 parent 96d537a commit fe97bb0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

en/django_orm/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ We can also reverse the ordering by adding `-` at the beginning:
130130
>>> Post.objects.order_by('-created_date')
131131
[<Post: 4th title of post>, <Post: My 3rd post!>, <Post: Post number 2>, <Post: Sample title>]
132132

133+
134+
### Chaining querysets
135+
136+
You can also combine QuerySets by **chaining** them together:
137+
138+
>>> Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
139+
140+
This is really powerful and lets you write quite complex queries.
141+
133142
Cool! You're now ready for the next part! To close the shell, type this:
134143

135144
>>> exit()

0 commit comments

Comments
 (0)