D:\mysite> py manage.py shell
Traceback (most recent call last):
File "manage.py", line 22, in
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\python\lib\site-packages\django\core\management_init.py", line 419, in execute_from_command_line
utility.execute()
File "C:\python\lib\site-packages\django\core\management_init.py", line 395, in execute
django.setup()
File "C:\python\lib\site-packages\django_init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\python\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\python\lib\site-packages\django\apps\config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "C:\python\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 724, in exec_module
File "", line 860, in get_code
File "", line 791, in source_to_code
File "", line 219, in _call_with_frames_removed
File "D:\mysite\polls\models.py", line 22
def str(self):
^
IndentationError: unexpected indent
如果是创建的django文件代码缩进有问题可以改,但是c盘都是源文件代码,没有改过,怎么会提示代码缩进错误提示呀,请教各位技术大咖,这个怎么改进呀。
运行py manage.py shell命令时出现错误
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-HGJ 2021-07-12 14:06关注
错误提示是models.py代码中第22行有缩进错误,你检查一下看看这个文件,是不是复制粘贴造成的,将def str(self)按代码逻辑调整缩进和对齐,通过del空格和tab缩进消除不可见字符。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 已经买的资源,运行有点问题
- ¥15 Coze智能助手搭建过程中的问题请教
- ¥15 12864只亮屏 不显示汉字
- ¥20 三极管1000倍放大电路
- ¥15 vscode报错如何解决
- ¥15 前端vue CryptoJS Aes CBC加密后端java解密
- ¥15 python随机森林对两个excel表格读取,shap报错
- ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
- ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
- ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值