0
カスタムDjango認証モデルを作成するためのコードを作成しましたが、カスタムユーザーマネージャを使用してスーパーユーザーを作成しようとしていますが、python manage.py createsuperuserコマンドを使用しようとすると、次のエラー:TypeError: create_superuser() got an unexpected keyword argument 'password'
カスタム認証モデル用のcreate_superuser
UserHandler/models.py
# Custom Auth Manager
class AuthManager(BaseUserManager):
def create_superuser(self, supplied_email, supplied_password, supplied_first_name, supplied_last_name, supplied_language):
# Make this password great again (w/ salting and hashing)
hashed_salted_password = AbstractBaseUser.set_password(supplied_password)
superuser = AuthLookup()
superuser.email_address = supplied_email
superuser.password = hashed_salted_password
superuser.first_name = supplied_first_name
superuser.last_name = supplied_last_name
superuser.language = supplied_language
superuser.save()
# Abstract Auth Model
class AuthLookup(AbstractBaseUser, PermissionsMixin):
email_address = models.EmailField(unique=True)
password = models.CharField(max_length=100)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
organization_id = models.UUIDField(null=False, max_length=36, default=uuid.uuid4)
# Firebase tokens(Max length represents 5 device tokens at maximum length of 256 characters plus 4 commas.)
associated_devices = models.CharField(max_length=1284)
is_requester = models.BooleanField(null=False, default=0)
is_responder = models.BooleanField(null=False, default=0)
user_identifier = models.UUIDField(null=False, max_length=36, default=uuid.uuid4)
language = models.CharField(max_length=6, default='US_EN')
user_added = models.DateTimeField(default='1970-01-01 00:00:00')
object = AuthManager()
USERNAME_FIELD = 'email_address'
REQUIRED_FIELDS = ['first_name', 'last_name', 'language']
Settings.py
AUTH_USER_MODEL = 'UserHandler.AuthLookup'