

def lookup_foreign_key_field(self, options, field_name):
    'Make a field lookup converting __ into real models fields'
    if ('__' in field_name):
        (fk_name, field_name) = field_name.split('__', 1)
        fields = [f for f in options.fields if (f.name == fk_name)]
        if (len(fields) > 0):
            field_class = fields[0]
        else:
            raise FieldError(('No field %s in %s' % (fk_name, options)))
        foreign_model_options = field_class.rel.to._meta
        return self.lookup_foreign_key_field(foreign_model_options, foreign_model_options)
    else:
        return options.get_field_by_name(field_name)

dataset/ETHPy150Open gerry/django-jqgrid/jqgrid.py JqGrid.lookup_foreign_key_field/VarMisuse@116/185 `field_name`->`foreign_model_options`