<s> from django . conf import settings <EOL> from django . db import models <EOL> class ModelBase ( models . Model ) : <EOL> """<STR_LIT>""" <EOL> class Meta : <EOL> abstract = True <EOL> def update ( self , ** kw ) : <EOL> """<STR_LIT>""" <EOL> signal = kw . pop ( '<STR_LIT>' , True ) <EOL> cls = self . __class__ <EOL> for k , v in kw . items ( ) : <EOL> setattr ( self , k , v ) <EOL> if signal : <EOL> attrs = dict ( self . __dict__ ) <EOL> models . signals . pre_save . send ( sender = cls , instance = self ) <EOL> for k , v in self . __dict__ . items ( ) : <EOL> if attrs [ k ] != v : <EOL> kw [ k ] = v <EOL> setattr ( self , k , v ) <EOL> cls . objects . filter ( pk = self . pk ) . update ( ** kw ) <EOL> if signal : <EOL> models . signals . post_save . send ( sender = cls , instance = self , <EOL> created = False ) <EOL> class LocaleField ( models . CharField ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , max_length = <NUM_LIT:7> , default = settings . LANGUAGE_CODE , <EOL> choices = settings . LANGUAGE_CHOICES , * args , ** kwargs ) : <EOL> return super ( LocaleField , self ) . __init__ ( <EOL> max_length = max_length , default = default , choices = choices , <EOL> * args , ** kwargs ) </s>
