
django
爱的太深,太认真
这段程序不太冷
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Exception Value: Could not parse some characters:xxxx
Exception Value: Could not parse some characters: clsi.Child|-node| |safe遇到这个错大概率是因为你在定义使用Django模板渲染时一些格式错误以上错误是因为:我在定义dict时key字符加了“-”,html解析失败dict={"a-b":"value"} #这样定义{{dict.a-v |seaf}}#模板这样调用,问题就出在这,html会把-识别为其他解决方法定义字典时key不要有“-”可以使用“_”...原创 2021-09-02 10:59:16 · 941 阅读 · 0 评论 -
RuntimeError: cannot cache function ‘__shear_dense‘: no locator available for file ‘/usr/local/lib/p
RuntimeError: cannot cache function '__shear_dense': no locator available for file '/usr/local/lib/python3.6/site-packages /librosa/util/utils.py',原创 2021-07-20 19:38:48 · 2115 阅读 · 0 评论 -
raise MigrationSchemaMissing(“Unable to create the django_migrations table (%s)“ % exc) django.db.mi
raise MigrationSchemaMissing(“Unable to create the django_migrations table (%s)” % exc)django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, “You h ave an error in your SQL syntax; che原创 2021-07-14 17:08:31 · 383 阅读 · 0 评论 -
Django缓存清理和缓存设置
Django缓存清理和缓存设置缓存清理方法很多,提供两个思路1、直接去清理用来存缓存的介质,如memcached、redis()2、自己写程序脚本清空。3、使用django-extensions来清空缓存2、自己写程序脚本清空步骤:1、给manage.py添加自定义命令,用来执行写好的脚本。如python manage.py cleancache #清空缓存++obj±-obj±-app01–management–commandes– cleancache .py–如上转载 2021-07-01 18:54:19 · 5873 阅读 · 0 评论 -
Django 实现在线预览pdf、word、xls、ppt等文件
Django 实现在线预览pdf、word、xls、ppt等文件1、将文件加入静态资源2、配置视图函数views.pydef help(request): return render(request, 'help.html')3、html<object type="application/pdf" data='../../static/help/xxxx.pdf' width="100%" height="620px"> ></object>最终呈现原创 2021-06-28 17:53:07 · 7046 阅读 · 7 评论 -
AttributeError: ‘xxx‘ object has no attribute ‘session‘
AttributeError: ‘xxx’ object has no attribute ‘session’出现这个错误呢,是你在使用装饰器验证用户是否登录的时候,装饰器函数里面用到了request参数,从request.session中获取用户是否登录。错误原因是你的装饰器用法错误。装饰器def check_login(func): @wraps(func) def wrappers(request,*args, **kwargs): if request.sess原创 2021-06-21 15:42:51 · 3389 阅读 · 0 评论 -
AttributeError: ‘function‘ object has no attribute ‘as_view‘
AttributeError: ‘function’ object has no attribute 'as_view’原因大概率是因为你的格式不正确,正确格式如下自行对照。obj文件夹下urls.pyfrom django.urls import path, re_pathfrom obj import viewsapp_name = "obj"urlpatterns = [ re_path(r"Crdel", views.Createmodel.as_view(), name='原创 2021-06-21 14:24:14 · 4319 阅读 · 0 评论 -
2021-06-09WARNINGS: ?: (2_0.W001) Your URL pattern。。。。This was likely an oversight when migrating to
WARNINGS:?: (2_0.W001) Your URL pattern ‘qweq/^(?P<fi3_33id>\d+)KaTeX parse error: Expected group after '^' at position 67: …begins with a '^̲', or ends wit…’. This was likely an oversight when migrating to django.urls.path().报以上错误怎莫办?先不要慌urls.py原创 2021-06-09 16:53:35 · 560 阅读 · 1 评论 -
Django admin选择一个有效的选项,xx不在可用的选项中。解决办法及原因
发生以上状况,看你的代码大致应该是这样的吧,前后要对应,不能前面是字符,后面是int原创 2021-06-07 22:14:56 · 1355 阅读 · 0 评论 -
?: (staticfiles.E002) The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting.
File "C:\Users\python\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Users\python\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Users\admin\Desktop\untitled66\lib\site-packages\dj...原创 2021-06-07 15:31:13 · 1443 阅读 · 1 评论 -
Django QuerySet转化为JSON
DjangoQuerySet转化为JSONValues QuerySet转JSON方式import jsondata = json.dumps(list(my_table.objects.all().values()))这种方法也不是万能,有时候你会发现打印出来就是list类型,但是偏偏还会报错,还是转不了,在Django 中有个小坑如果查出的QuerySet包含其他非字符类型需要在转jsonq前转,否则报错例如看你的代码中是否有时间类型数据。如果有你需要使用以下语句转换、代码如下:.e原创 2021-05-21 12:55:28 · 2581 阅读 · 0 评论 -
Django TemplateDoesNotExist err 解决方发
我的目录结构如上解决办法:在seting.py中‘DIRS’: [os.path.join(BASE_DIR,‘templates’).replace(’\’, ‘/’),],原创 2021-05-21 00:51:38 · 662 阅读 · 0 评论