#NEWLINE# def __init__( self , widget , rel , admin_site , can_add_related = None , can_change_related = False , can_delete_related = False ) : #NEWLINE# #INDENT# self . needs_multipart_form = widget . needs_multipart_form #NEWLINE# self . attrs = widget . attrs #NEWLINE# self . choices = widget . choices #NEWLINE# self . widget = widget #NEWLINE# self . rel = rel #NEWLINE# if ( can_add_related is None ) : #NEWLINE# #INDENT# can_add_related = ( rel . model in admin_site . _registry ) #NEWLINE# #UNINDENT# self . can_add_related = can_add_related #NEWLINE# multiple = getattr ( admin_site , 'allow_multiple_selected' , False ) #NEWLINE# self . can_change_related = ( ( not multiple ) and can_change_related ) #NEWLINE# cascade = ( getattr ( rel , 'on_delete' , None ) is CASCADE ) #NEWLINE# self . can_delete_related = ( ( not multiple ) and ( not cascade ) and can_delete_related ) #NEWLINE# self . admin_site = admin_site