gpt4 book ai didi

python - Django - 在 'INSTALLED APPS' 中添加应用程序名称时出现值错误

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

当我在 settings.py 文件内的已安装应用程序中添加我的应用程序名称时,出现以下错误,当我从设置中删除我的应用程序名称时,该错误被删除。这里有什么问题吗?

Unhandled exception in thread started by <function check_errors. 
<locals>.wrapper at 0x0000007BFA7BB598>
Traceback (most recent call last):
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\core\management\commands\runserver.py", line 117, in
inner_run autoreload.raise_last_exception()
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\utils\autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Users\postgres\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)

return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes

最佳答案

我遇到了和你几乎一样的问题。最后,我发现我的问题来自应用程序中的models.py,它是由命令“python manage.pyspectdb > models.py”生成的。这个models.py不是utf-8格式。你可以用notepad++打开它并更改格式并保存。然后,一切就OK了。

关于python - Django - 在 'INSTALLED APPS' 中添加应用程序名称时出现值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50779715/

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