gpt4 book ai didi

python - Django,在 Visual Studio 命令行上运行 'createsuperuser' 错误

转载 作者:行者123 更新时间:2023-12-01 01:43:14 25 4
gpt4 key购买 nike

嗨,

我想在 Visual Studio 中使用 Python 3.7 和 Django 2.1。我刚刚从 Visual Studio 创建了一个新的 Django 项目。它创建了 Python-Django 项目。

But when I try to run 'createsuperuser' command from command-line on Visual Studio, I am getting this long error text.

我的计算机上有 Python 3.7 和 Django 2.1 版本,所以我认为这与版本无关。

如何解决这个问题?

Traceback (most recent call last):
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 59, in execute
return super().execute(*args, **options)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Python\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File ".\DjangoWebProject7\urls.py", line 23, in <module>
django.contrib.auth.views.login,
AttributeError: module 'django.contrib.auth.views' has no attribute 'login'

最佳答案

django.contrib.auth.views.login 已在 django 2.1 中删除。来自 Release notes :

contrib.auth.views.login(), logout(), password_change(), password_change_done(), password_reset(), password_reset_done(), password_reset_confirm(), and password_reset_complete() are removed.

您现在应该使用基于类的 View django.contrib.auth.views.LoginView在你的网址中,例如最简单的形式:

path('login/', LoginView.as_view()),

关于python - Django,在 Visual Studio 命令行上运行 'createsuperuser' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51667115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com