gpt4 book ai didi

python - 类型错误 : argument of type 'WindowsPath' is not iterable - in django python

转载 作者:行者123 更新时间:2023-12-04 11:16:50 37 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Getting a typeError error in django project

(3 个回答)


12 个月前关闭。




每当我运行服务器或在终端中执行任何命令时,都会在终端中显示此错误。服务器正在运行并且网页工作正常,但是当我退出服务器或运行任何命令(如 python manage.py migrate)时,会显示此错误。

   `Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 21, 2020 - 12:42:24
Django version 3.0, using settings 'djangoblog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

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:\Python37\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python37\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python37\lib\site-packages\django\core\management\base.py", line 341, in run_from_argv
connections.close_all()
File "C:\Python37\lib\site-packages\django\db\utils.py", line 230, in close_all
connection.close()
File "C:\Python37\lib\site-packages\django\utils\asyncio.py", line 24, in inner
return func(*args, **kwargs)
File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\base.py", line 261, in close
if not self.is_in_memory_db():
File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\base.py", line 380, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Python37\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
`

最佳答案

我通过更改 settings.py 文件中的 DATABASES 清除了此问题:
改变

'NAME': BASE_DIR / 'db.sqlite3',
'NAME': str(os.path.join(BASE_DIR, "db.sqlite3"))

这有效
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': str(os.path.join(BASE_DIR, "db.sqlite3"))
}
}

关于python - 类型错误 : argument of type 'WindowsPath' is not iterable - in django python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63987965/

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