django 3.2-在 sqlite3 中创建超级用户时出错
django 3.2- error creating superuser in sqllite3
PS C:\Users\Abdulla Zia\PycharmProjects\EnhanceImage> python manage.py createsuperuser
Username (leave blank to use 'abdullazia'): admin
Email address:
Password:
Password (again):
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 79, in execute
return super().execute(*args, **options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 157, in handle
validate_password(password2, self.UserModel(**fake_user_data))
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 44, in validate_password
password_validators = get_default_password_validators()
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 19, in get_default_password_validators
return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 30, in get_password_validators
validators.append(klass(**validator.get('OPTIONS', {})))
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 174, in __init__
with gzip.open(password_list_path, 'rt', encoding='utf-8') as f:
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\lib\gzip.py", line 57, in open
raise TypeError("filename must be a str or bytes object, or a file")
TypeError: filename must be a str or bytes object, or a file
执行了所有迁移仍然出现此错误。我已经删除了数据库文件并创建了一个新文件,但仍然出现相同的错误。服务器已启动并且 运行 没有任何错误
请进行迁移并尝试创建超级用户
试试这个
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
或在您的初始迁移时尝试此操作
python manage.py migrate
python manage.py createsuperuser
PS C:\Users\Abdulla Zia\PycharmProjects\EnhanceImage> python manage.py createsuperuser
Username (leave blank to use 'abdullazia'): admin
Email address:
Password:
Password (again):
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 79, in execute
return super().execute(*args, **options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 157, in handle
validate_password(password2, self.UserModel(**fake_user_data))
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 44, in validate_password
password_validators = get_default_password_validators()
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 19, in get_default_password_validators
return get_password_validators(settings.AUTH_PASSWORD_VALIDATORS)
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 30, in get_password_validators
validators.append(klass(**validator.get('OPTIONS', {})))
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\contrib\auth\password_validation.py", line 174, in __init__
with gzip.open(password_list_path, 'rt', encoding='utf-8') as f:
File "C:\Users\Abdulla Zia\AppData\Local\Programs\Python\Python37\lib\gzip.py", line 57, in open
raise TypeError("filename must be a str or bytes object, or a file")
TypeError: filename must be a str or bytes object, or a file
执行了所有迁移仍然出现此错误。我已经删除了数据库文件并创建了一个新文件,但仍然出现相同的错误。服务器已启动并且 运行 没有任何错误
请进行迁移并尝试创建超级用户 试试这个
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
或在您的初始迁移时尝试此操作
python manage.py migrate
python manage.py createsuperuser