在django中使用bootstrap4报错:OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: ‘「frozen importlib._bootstrap」‘”

在aototest/settings.py 中加入如下内容:

INSTALL_APPS = (#...'bootstrap4',#...

在product_manage.html中:

# {# Load the tag library #}
{% load bootstrap4 %}# {# Load CSS and JavaScript #}
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}

随后访问 http://127.0.0.1:8000/product_manage/
链接失败。
查看development server已自动退出,重启server:

C:\Users\Jhin\AppData\Local\Programs\Python\Python37\Scripts\autotest>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_innerself.run()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in runself._target(*self._args, **self._kwargs)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 53, in wrapperfn(*args, **kwargs)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\commands\runserver.py", line 109, in inner_runautoreload.raise_last_exception()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 76, in raise_last_exceptionraise _exception[1]File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\__init__.py", line 357, in executeautoreload.check_errors(django.setup)()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 53, in wrapperfn(*args, **kwargs)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\__init__.py", line 24, in setupapps.populate(settings.INSTALLED_APPS)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\apps\registry.py", line 91, in populateapp_config = AppConfig.create(entry)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\apps\config.py", line 90, in createmodule = import_module(entry)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 1006, in _gcd_importFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'bootstrap'Traceback (most recent call last):File "manage.py", line 21, in <module>main()File "manage.py", line 17, in mainexecute_from_command_line(sys.argv)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\__init__.py", line 401, in execute_from_command_lineutility.execute()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\__init__.py", line 395, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\base.py", line 328, in run_from_argvself.execute(*args, **cmd_options)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\commands\runserver.py", line 60, in executesuper().execute(*args, **options)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\base.py", line 369, in executeoutput = self.handle(*args, **options)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\commands\runserver.py", line 95, in handleself.run(**options)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\core\management\commands\runserver.py", line 102, in runautoreload.run_with_reloader(self.inner_run, **options)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 599, in run_with_reloaderstart_django(reloader, main_func, *args, **kwargs)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 584, in start_djangoreloader.run(django_main_thread)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 299, in runself.run_loop()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 305, in run_loopnext(ticker)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 345, in tickfor filepath, mtime in self.snapshot_files():File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 361, in snapshot_filesfor file in self.watched_files():File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 260, in watched_filesyield from iter_all_python_module_files()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 105, in iter_all_python_module_filesreturn iter_modules_and_files(modules, frozenset(_error_files))File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.8-py3.7.egg\django\utils\autoreload.py", line 141, in iter_modules_and_filesresolved_path = path.resolve(strict=True).absolute()File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 1161, in resolves = self._flavour.resolve(self, strict=strict)File "C:\Users\Jhin\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 200, in resolvereturn self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: '<frozen importlib._bootstrap>'

百度几天均无果,后重新安装bootstrap

pip install django-bootstrap4

runserver还是一样的报错。
重新运行:

python manage.py migrate

随后runserver成功:

C:\Users\Jhin\AppData\Local\Programs\Python\Python37\Scripts\autotest>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...System check identified no issues (0 silenced).
July 13, 2020 - 03:12:05
Django version 3.0.8, using settings 'autotest.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[13/Jul/2020 03:12:15] "GET /product_manage/ HTTP/1.1" 200 2399

总结为先

python manage.py migrate

python manage.py runserver

就成功了(不知道为啥,手动狗头)
截图为证:

卡了我几天的坑,记录一下。

报错:TemplateSyntaxError at /apistep_manage/

Invalid block tag on line 48: ‘else’, expected ‘empty’ or ‘endfor’. Did you forget to register or load this tag?

几经排查后还是找不到原因,后受文章 传送门 的启发,在if开始时的地方查找,找到问题所在:

此处少了一个百分号%,添加上之后,报错解决。

报错:TemplateSyntaxError at /apistep_manage/

Could not parse the remainder: ‘% if apistep.apistatus == 1 %’ from ‘% if apistep.apistatus == 1 %’


经排查,系此处多了一对花括号,去除一对花括号后,该报错解决。

报错:Unclosed tag on line 37: ‘for’. Looking for one of: empty, endfor.


后排除问题如下:

最后显示界面如下:

总结:一定要注意百分号空格/百分号是否成对/一对百分号是否写成了两对。。。引以为戒中。。。

报错:TypeError: bug_manage() missing 1 required positional argument: ‘request’


经排查,系此处括号有问题:

runserver时报错:

raise RuntimeError(“cryptography is required for sha256_password or caching_sha2_password”)
RuntimeError: cryptography is required for sha256_password or caching_sha2_password
原因是没有连接数据库。

前端界面异常

搭建测试平台的时候,出现前端一场:

经排查,乃一低级错误:

如图所示,container写到了引号外面(手动狗头),修改后显示正常。

django踩坑记录相关推荐

  1. django踩坑记录(4)

    0x0d.如何设置不同登录方式,显示不同的标签及对应的form表单的字段?下面代码超级多细节,真的值得看 描述的情景如下图: 代码实现思路:两个不同的登录方式是:账号密码登录和使用短信验证码登录. 1 ...

  2. 日常踩坑记录-汇总版

    开发踩坑记录,不定时更新 心得 RTFM 严谨的去思考问题,处理问题 严格要求自己的代码编写习惯与风格 注意 单词拼写 20200207 mybatis plus 自带insert插入异常 sql i ...

  3. 为Jupyter notebook配置R kernel过程及踩坑记录

    为Jupyter notebook配置R kernel过程及踩坑记录 注意:本文为作者安装过程及折腾的过程,内容比较冗杂,如果读者想直接创建一个属于自己的子环境则参考: 如下文章: anaconda下 ...

  4. Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子

    Python打包工具Pyintealler打包py文件为windows exe文件过程及踩坑记录+实战例子 目录 Python打包工具Pyintealler打包py文件为windows exe文件过程 ...

  5. TVM: Deep Learning模型的优化编译器(强烈推荐, 附踩坑记录)

    本文作者是阿莱克西斯,原载于知乎,雷锋网(公众号:雷锋网)获得授权转载. (前排提醒,本文的人文内容部分稍稍带有艺术加工,请保持一定的幽默感进行阅读) 关注我最近想法的同学应该知道我最近都在把玩 TV ...

  6. 使用Java读取 “Python写入redis” 的数据踩坑记录

    https://my.oschina.net/u/2338224/blog/3061507 使用Java读取 "Python写入redis" 的数据踩坑记录 https://seg ...

  7. osx php7 imagick,[PHP] MacOS 自带php环境安装imagick扩展踩坑记录 | 码农部落

    前言 最近学习yii2,在搭建环境后,发现在访问contact页面时报错,如下: "Either GD PHP extension with FreeType support or Imag ...

  8. vue-i18n使用及踩坑记录

    使用步骤 1. 安装 npm i vue-i18n 2. vue-cli下使用 //1. 引入 vue-i18n import Vue from 'vue' import VueI18n from ' ...

  9. SpringBoot踩坑记录 Invalid bound statement (not found)引发的一些列问题

    SpringBoot踩坑记录 Invalid bound statement (not found)引发的一些列问题 当你开开心心搭建了一个SpringBoot项目,用插件生成了entity.dao. ...

  10. mysql 使用sum limit_mysql踩坑记录之limit和sum函数混合使用问题

    问题复盘 本次复盘会用一个很简单的订单表作为示例. 数据准备 订单表建表语句如下(这里偷懒了,使用了自增ID,实际开发中不建议使用自增ID作为订单ID) CREATE TABLE `order` ( ...

最新文章

  1. HDU 4300 Clairewd’s message
  2. Fsharp 类中的空字段
  3. Jenkins 使用 Kubernetes Plugin 完成持续构建与发布
  4. 最长不下降子序列java代码_浅谈最长不下降子序列与最长上升子序列
  5. 安装memory analyzer
  6. SELECT LAST_INSERT_ID() 的使用和注意事项
  7. API接口设计 注意问题
  8. python循环指令_Python循环
  9. 睡眠音频分割及识别问题(一)
  10. 【手把手 脑把脑】教会你使用idea基于MapReduce的统计数据分析(从问题分析到代码编写)
  11. Struts 拦截器
  12. pwm一个时间单位_通过PWM进行数模转换的滤波电路分析计算
  13. ***CI的CLI运行方式
  14. PCA(主成分分析)的简单理解
  15. 2019最新大数据分析智能BI Tableau教程视频(18章节)
  16. csv文件超过104万数据怎么办
  17. 使用Cent Browser+Aria2+Bilibili Envolved下载b站视频--保姆级安装步骤
  18. 中乾山东最专业众筹系统
  19. ​史上解释CRC最清楚的文章
  20. IBM powerVC云管平台

热门文章

  1. 树莓派平台的ADXL345三轴加速度传感器编程
  2. linux 如何解压z01文件
  3. Java、三角形类Triangle
  4. bitcode 是什么_secured是什么意思 Secured borrowings是什么意思
  5. 以图搜图-自动生成图模式匹配Cypher
  6. 不羞涩社区图片爬取,我真的不是为了看小姐姐私照,从未这么渴望过知识!
  7. Batch Normalization :深度网络中的BN层
  8. PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive Summarization
  9. [译] 为什么你要学习 Go?
  10. PMBOK(第六版) 学习笔记 ——《第五章 项目范围管理》