Skip to content

Instantly share code, notes, and snippets.

@debanshuk
debanshuk / django-custom-join.py
Last active May 21, 2024 00:52
Utility functions to add join to queryset or a table to a django ORM queryset.
from django.db.models.fields.related import ForeignObject
from django.db.models.options import Options
from django.db.models.sql.constants import LOUTER
from django.db.models.sql.datastructures import Join
from django.db.models.sql.where import ExtraWhere
class CustomJoin(Join):
def __init__(self, subquery, subquery_params, parent_alias, table_alias, join_type, join_field, nullable):
self.subquery_params = subquery_params