#NEWLINE# def pre_save( self , instance , add ) : #NEWLINE# #INDENT# default = super ( AutoSlugField , self ) . pre_save ( instance , add ) #NEWLINE# if ( default or ( not add ) or ( not self . populate_from ) ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# value = getattr ( instance , self . populate_from ) #NEWLINE# if ( value is None ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# slug = slugify ( smart_text ( value ) ) [ : self . max_length ] . strip ( '-' ) #NEWLINE# setattr ( instance , self . attname , slug ) #NEWLINE# return slug