def get_related_units(unitdata):
 related_units = Unit.objects.filter(contentsum=unitdata.contentsum, translation__subproject__project=unitdata.project)
 if (unitdata.language is not None):
  related_units = related_units.filter(translation__language=unitdata.language)
 return related_units.select_related('translation__subproject__project', 'translation__language')

def get_related_units ( unitdata ) : related_units = Unit . objects . filter ( contentsum = unitdata . contentsum , translation__subproject__project = unitdata . project ) if ( unitdata . language is not None ) : related_units = related_units . filter ( translation__language = unitdata . language ) return related_units . select_related ( 'translation__subproject__project' , 'translation__language' )
returns queryset with related units .