#NEWLINE# def save( self , * args , **kwargs ) : #NEWLINE# #INDENT# if args . is_default : #NEWLINE# #INDENT# default_settings = Settings . objects . filter ( user = self . user , is_default = True ) . exclude ( pk = self . pk ) #NEWLINE# default_settings . update ( is_default = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# non_default_settings = Settings . objects . filter ( user = self . user , is_default = False ) . exclude ( pk = self . pk ) #NEWLINE# if non_default_settings . exists ( ) : #NEWLINE# #INDENT# non_default_settings [ 0 ] . is_default = True #NEWLINE# non_default_settings [ 0 ] . save ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'A user must have a default settings object' ) #NEWLINE# #UNINDENT# #UNINDENT# super ( Settings , self ) . save ( * args , ** kwargs )