generate series & cross join

Hello !

I am trying to generate an initial queryset consisting of a CROSS JOIN between a generated date sequence using Postgres generate_series and another table Foo (resulting in a generated table containing each item of Foo for each date, the cartesian product).

I would like to use the Django ORM because I have a lot of post-processing to do after that, with filters, annotations, sub-queries, aggregations, etc.

I found a raw SQL answer to a very similar question here:

And a library implementing generate_series for Django ORM:
https://django-generate-series.readthedocs.io/en/latest/

How would you go about that ? Is it possible ?

If not, how would you go about customizing the ORM to be able to handle this type of use cases ?

Thanks in advance,
Lionel