| | 209 | .. note:: ``all()`` is lazy |
|---|
| | 210 | |
|---|
| | 211 | It might look a little frightening to see ``Poll.objects.all()`` being used |
|---|
| | 212 | in a detail view which only needs one ``Poll`` object, but don't worry; |
|---|
| | 213 | ``Poll.objects.all()`` is actually a special object called a ``QuerySet``, |
|---|
| | 214 | which is "lazy" and doesn't hit your database until it absolutely has to. By |
|---|
| | 215 | the time the database query happens, the ``object_detail`` generic view will |
|---|
| | 216 | have narrowed its scope down to a single object, so the eventual query will |
|---|
| | 217 | only select one row from the database. |
|---|
| | 218 | |
|---|
| | 219 | If you'd like to know more about how that works, The Django database API |
|---|
| | 220 | documentation `explains the lazy nature of QuerySet objects`_. |
|---|
| | 221 | |
|---|
| | 222 | .. _explains the lazy nature of QuerySet objects: ../db_api/#querysets-are-lazy |
|---|
| | 223 | |
|---|