1:创建  templatetags文件夹 2:创建simpletags.py文件将内容粘贴进去,在下面 3:setting.py添加文件指定: 1 TEMPLATES = [ 2 { 3 'BACKEND': 'django.template.backends.django.DjangoTemplates', 4 'DIRS': [BASE_DIR+"/templates", ], 5 'APP_DIRS': True, 6 'OPTIONS': { 7 'context_proce…
django正常运行却报错的处理方法 出处 : https://www.infvie.com/ops-notes/django-normal-operation-error 报错一:self._sock.sendall(b) ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接. 解决方法:找到python/Lib/socketserver.py文件,修改SocketWriter类的write方法,具体如下: def write…
You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. 我看视频时,看到了django自带的admin管理,然后根据视频中的代码 python manage.py…
编码信息导致修改django文件下的debug.py文件331行的编码格式 with Path(CURRENT_DIR, 'templates', 'technical_500.html').open(encoding="utf-8") as fh:…
django.template.exceptions.TemplateSyntaxError: 'article_tags' is not a registered tag library. Must be one of:admin_listadmin_modifyadmin_staticadmin_urlscachei18nl10nlogstaticstaticfilestz 解决:新增下面椭圆里面的内容…
在访问web页面时报错,详细日志如下: django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:admin_listadmin_modifyadmin_urlscachei18nl10nlogrest_frameworkstatictz 解决办法: 指定staticfiles settings.py 文件中TEMPLATES中的OPT…
报错代码: 'selffilter' is not a registered tag library. Must be one of: admin_list admin_modify admin_static admin_urls cache i18n l10n log static staticfiles tz 解决方法: 错误可能: 1. 在你的app目录下新建templatetags文件夹里没创建__init__.py定义为包 2. 程序编写问题 在templatetags下创建myfil…
我写代码遇到这个错误,但是发现程序没有写错,好像是程序有缓存,重新运行几次就好了. 自定义模板标签,可以不用写views,url直接通过自定义函数把变量传给模板. 具体实现: 1.在app下新建Python Package,会自动有个__init__.py的文件 然后新建文件XXXX.py,如myblogs.py,这个自己命名,myblogs.py代码如下: from django import templatefrom blogs.models import Post# Post是函数要用的m…
确保每次修改模板标签时都重新启动 Django 开发服务器(或确保它自己重新启动).如果服务器没有重新启动,Django 将不会注册标签. 从 django 1.9 开始,您可以在如下设置中加载这些新标签/过滤器: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors':…
报错: You are trying to add a non-nullable field 'BookName' to BookInfo without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing row…