# Query Assertions for Django
   
**GitHub:** https://github.com/beanbaginc/django-assert-queries
**PyPI:** https://pypi.org/project/django-assert-queries
**Status:** Under active development / released / used in production
ORMs. Love 'em or hate 'em, they're often part of the job, and a core part of writing [Django](https://djangoproject.com) webapps. They can make it easy to write queries that work across databases, but the trade-off is your queries might explode in number and in complexity.
Who hasn't made this mistake?
```python
for book in Book.objects.all():
print(f'Author: {book.author.name}')
```
Spot the error? We're fetching the associated author once for every book. For 100 books, that's 101 queries!
And that's just a really basic query.
These mistakes happen all the time, and they're not always easy to catch in unit tests.
That's what the clear-but-unimaginatively-named [django-assert-queries](https://pypi.org/project/django-assert-queries) is here to solve. With proper use, this can save companies from costly mistakes. [We've](https://www.reviewboard.org) found it to be an invaluable tool in our arsenal.