#NEWLINE# def __init__( self , admin_view , lookup , value ) : #NEWLINE# #INDENT# self . admin_view = admin_view #NEWLINE# self . org_model = admin_view . model #NEWLINE# self . opts = admin_view . opts #NEWLINE# self . lookup = lookup #NEWLINE# self . value = value #NEWLINE# parts = lookup . split ( LOOKUP_SEP ) #NEWLINE# field = self . opts . get_field ( parts [ 0 ] ) #NEWLINE# if ( not is_related_field2 ( field ) ) : #NEWLINE# #INDENT# raise Exception ( 'Relate Lookup field must a related field' ) #NEWLINE# #UNINDENT# if hasattr ( field , 'rel' ) : #NEWLINE# #INDENT# self . to_model = field . rel . to #NEWLINE# self . rel_name = field . rel . get_related_field ( ) . name #NEWLINE# self . is_m2m = isinstance ( field . rel , models . ManyToManyRel ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . to_model = field . model #NEWLINE# self . rel_name = self . to_model . _meta . pk . name #NEWLINE# self . is_m2m = False #NEWLINE# #UNINDENT# to_qs = self . to_model . _default_manager . get_queryset ( ) #NEWLINE# self . to_objs = to_qs . filter ( ** { #NEWLINE# #INDENT# self . rel_name : value , #NEWLINE# #UNINDENT# } ) . all ( ) #NEWLINE# self . field = field