#NEWLINE# def _open( self , name , mode = 'rb' ) : #NEWLINE# #INDENT# assert ( mode [ 0 ] in 'rwab' ) #NEWLINE# storage_attrs = self . _get_storage_attributes ( name ) #NEWLINE# model_class_path = storage_attrs [ 'model_class_path' ] #NEWLINE# content_field = storage_attrs [ 'content_field' ] #NEWLINE# filename_field = storage_attrs [ 'filename_field' ] #NEWLINE# mimetype_field = storage_attrs [ 'mimetype_field' ] #NEWLINE# filename = storage_attrs [ 'filename' ] #NEWLINE# model_cls = self . _get_model_cls ( model_class_path ) #NEWLINE# model_instance = model_cls . objects . only ( content_field , mimetype_field ) . get ( ** { #NEWLINE# #INDENT# filename_field : name , #NEWLINE# #UNINDENT# } ) #NEWLINE# encoded_bytes = getattr ( model_instance , content_field ) #NEWLINE# _file = self . _get_file_from_encoded_bytes ( encoded_bytes ) #NEWLINE# _file . filename = filename #NEWLINE# _file . mimetype = getattr ( model_instance , mimetype_field ) #NEWLINE# return _file