Is there any way to perform cross join (full cartesian) in Django ORM for 2 or more unrelated models? The reqult should be queryset, so I could apply filtering, annotation, e t.c. al usual.
Example for undependent models region and week:
values = region.objects.cross_join(week).filter(…).values_list(‘region_id’, ‘week_id’)
Resulting SQL: SELECT region.id, week.id FROM region CROSS JOIN week
So I need something like “cross_join”, but I cannot find it anywhere in Django ORM. I found qs.query.join, but it’s not what satisfies me.
Pandas using should be good altertative, but I prefer to stay with Django ORM.
There is one way I can think of right off-hand - create a view in the database to perform the join, a model in Django to correspond to that view, and then use the ORM for the remainder of the operations.