#NEWLINE# def patch_translation_field( self , db_field , field , **kwargs ) : #NEWLINE# #INDENT# if ( db_field . name in self . trans_opts . fields ) : #NEWLINE# #INDENT# if field . required : #NEWLINE# #INDENT# field . required = False #NEWLINE# field . blank = True #NEWLINE# self . _orig_was_required [ ( '%s.%s' % ( db_field . model . _meta , db_field . name ) ) ] = True #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# orig_field = db_field . translated_field #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# orig_formfield = self . formfield_for_dbfield ( orig_field , ** kwargs ) #NEWLINE# field . widget = deepcopy ( orig_formfield . widget ) #NEWLINE# if ( orig_field . name in self . both_empty_values_fields ) : #NEWLINE# #INDENT# from modeltranslation.forms import NullableField , NullCharField #NEWLINE# form_class = field . __class__ #NEWLINE# if issubclass ( form_class , NullCharField ) : #NEWLINE# #INDENT# form_class . __bases__ = tuple ( ( b for b in form_class . __bases__ if ( b != NullCharField ) ) ) #NEWLINE# #UNINDENT# field . __class__ = type ( ( 'Nullable%s' % form_class . __name__ ) , ( NullableField , form_class ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( ( ( db_field . empty_value == 'both' ) or ( orig_field . name in self . both_empty_values_fields ) ) and isinstance ( field . widget , ( forms . TextInput , forms . Textarea ) ) ) : #NEWLINE# #INDENT# field . widget = ClearableWidgetWrapper ( field . widget ) #NEWLINE# #UNINDENT# css_classes = field . widget . attrs . get ( 'class' , '' ) . split ( ' ' ) #NEWLINE# css_classes . append ( 'mt' ) #NEWLINE# css_classes . append ( build_css_class ( db_field . name , 'mt-field' ) ) #NEWLINE# if get_language_bidi ( db_field . language ) : #NEWLINE# #INDENT# css_classes . append ( 'mt-bidi' ) #NEWLINE# #UNINDENT# if ( db_field . language == mt_settings . DEFAULT_LANGUAGE ) : #NEWLINE# #INDENT# css_classes . append ( 'mt-default' ) #NEWLINE# if ( orig_formfield . required or self . _orig_was_required . get ( ( '%s.%s' % ( orig_field . model . _meta , orig_field . name ) ) ) ) : #NEWLINE# #INDENT# orig_formfield . required = False #NEWLINE# orig_formfield . blank = True #NEWLINE# field . required = True #NEWLINE# field . blank = False #NEWLINE# if isinstance ( field . widget , ClearableWidgetWrapper ) : #NEWLINE# #INDENT# field . widget = field . widget . widget #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# field . widget . attrs [ 'class' ] = ' ' . join ( css_classes )