#NEWLINE# def create( self , validated_data ) : #NEWLINE# #INDENT# now = timezone . now ( ) #NEWLINE# user = User ( email = validated_data . get ( 'email' ) , username = validated_data . get ( 'username' ) , last_login = now , date_joined = now , is_active = True ) #NEWLINE# if validated_data . get ( 'first_name' ) : #NEWLINE# #INDENT# user . first_name = validated_data [ 'first_name' ] #NEWLINE# #UNINDENT# if validated_data . get ( 'last_name' ) : #NEWLINE# #INDENT# user . last_name = self [ 'last_name' ] #NEWLINE# #UNINDENT# user . set_password ( validated_data [ 'password' ] ) #NEWLINE# if ( not User . objects . filter ( is_superuser = True ) . exists ( ) ) : #NEWLINE# #INDENT# user . is_superuser = user . is_staff = True #NEWLINE# #UNINDENT# user . save ( ) #NEWLINE# return user