django大佬
2021-07-12 11:38
采纳率: 100%
浏览 37

运行py manage.py shell命令时出现错误

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盘都是源文件代码,没有改过,怎么会提示代码缩进错误提示呀,请教各位技术大咖,这个怎么改进呀。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • CSDN专家-HGJ 2021-07-12 14:06
    已采纳

    错误提示是models.py代码中第22行有缩进错误,你检查一下看看这个文件,是不是复制粘贴造成的,将def str(self)按代码逻辑调整缩进和对齐,通过del空格和tab缩进消除不可见字符。

    点赞 打赏 评论
  • 吃肉的小馒头 2021-07-12 12:00

    File "D:\mysite\polls\models.py", line 22 这不是d盘么,只有错误没有代码怎么看

    点赞 打赏 评论

相关推荐 更多相似问题