# 18 - Working with Expression Wrappers: Filtering None?

**URL:** https://forum.codewithmosh.com/t/18-working-with-expression-wrappers-filtering-none/6423
**Category:** Django
**Created:** [July 29, 2021, 3:35am UTC](https://forum.codewithmosh.com/t/18-working-with-expression-wrappers-filtering-none/6423 "2021-07-29T03:35:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jlin](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@Jlin](https://forum.codewithmosh.com/u/Jlin)
#### Post date: [July 29, 2021, 3:35am UTC](https://forum.codewithmosh.com/t/18-working-with-expression-wrappers-filtering-none/6423/1 "2021-07-29T03:35:03Z")

</div>

In section 18 - Working with Expression Wrappers, I feel like there is something missing with the given exercises. For clarity, I am using postgres as my database.

On the last problem, “Top 5 best-selling products and their total sales”, the query returns a bunch of None values. This is something that we would want to filter out, so wouldn’t we want to add something like a .exclude(total\_sales\_\_isnull=True) before the order\_by and slicing?

Please let me know if this is a difference due to me using a postgres database.

Thanks

---

<div class="post-metadata">

### Author: ![Rajnish](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Rajnish](https://forum.codewithmosh.com/u/Rajnish)
#### Post date: [February 23, 2022, 3:26pm UTC](https://forum.codewithmosh.com/t/18-working-with-expression-wrappers-filtering-none/6423/2 "2022-02-23T15:26:00Z")

</div>

queryset = Product.objects.annotate(total\_quantity=Sum(‘orderitem\_\_quantity’)).filter(total\_quantity\_\_isnull=False).order\_by(’-total\_quantity’)[:5]

This is what I have coded, but it only gives the top 5 best-selling products based on the quantity.

But I have a few questions regarding the logic applied in the solution provided by Mosh. He has deduced the best-selling products based on the sales value and not the total quantity.
