<s> from django . conf import settings <EOL> if settings . AUTH_USER_MODEL == '<STR_LIT>' : <EOL> from django . contrib . auth . models import ( AbstractBaseUser , PermissionsMixin , <EOL> UserManager as BaseUserManager ) <EOL> from django . db import models <EOL> class UserManager ( BaseUserManager ) : <EOL> def _create_user ( self , username , email , password , <EOL> is_staff , is_superuser , ** extra_fields ) : <EOL> """<STR_LIT>""" <EOL> email = self . normalize_email ( email ) <EOL> user = self . model ( email = email , is_staff = is_staff , <EOL> is_superuser = is_superuser , ** extra_fields ) <EOL> user . set_password ( password ) <EOL> user . save ( using = self . _db ) <EOL> return user <EOL> def create_user ( self , username , email = None , password = None , ** extra_fields ) : <EOL> return self . _create_user ( username , email , password , False , False , ** extra_fields ) <EOL> def create_superuser ( self , username , email , password , ** extra_fields ) : <EOL> return self . _create_user ( username , email , password , True , True , ** extra_fields ) <EOL> class User ( AbstractBaseUser , PermissionsMixin ) : <EOL> """<STR_LIT>""" <EOL> email = models . EmailField ( blank = True , unique = True ) <EOL> is_staff = models . BooleanField ( default = False ) <EOL> objects = UserManager ( ) <EOL> USERNAME_FIELD = '<STR_LIT:email>' <EOL> def get_short_name ( self ) : <EOL> return self . email . split ( '<STR_LIT:@>' ) [ <NUM_LIT:0> ] </s>
