# Aggregate/annotate based on 2 different models

**URL:** <https://forum.djangoproject.com/t/aggregate-annotate-based-on-2-different-models/16663>\
**Category:** Using the ORM\
**Created:** [October 26, 2022, 10:08am UTC](https://forum.djangoproject.com/t/aggregate-annotate-based-on-2-different-models/16663 "2022-10-26T10:08:37Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 31, 2022, 4:36pm UTC](https://forum.djangoproject.com/t/aggregate-annotate-based-on-2-different-models/16663/8 "2022-10-31T16:36:35Z")

</div>

Just a side note, without addressing the specifics of the implementation of your `available` method:

In general, this type of function more properly belongs in a [custom model manager](https://docs.djangoproject.com/en/4.1/topics/db/managers/#managers) and _not_ in the model itself.

A model method should relate to one specific instance of the model. A model manager method is more appropriate where the method refers to a collection of model instances. That type of method can be used directly to retrieve a value, or be written as a subquery to be used within other queries, or as a custom queryset - you have lots of options at that point.

---

_[View the full topic](https://forum.djangoproject.com/t/aggregate-annotate-based-on-2-different-models/16663)._
