About the Underscore in Django Shell

In the Django Interactive Shell or Python Shell, underscore (_) refers to the result of the previously executed command.

1
2
3
>>> Post.objects.filter(title="Hello, World!")
[<Post: Hello, World!>, <Post: Hello, World!>]
>>> post1, post2 = _

Tips and Tricks Development Django 5.x Django 4.2 Django 3.2 Python 3