![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
django
那年秋天梦幻
说故事一般道尽人间甘苦
展开
-
windows centos python html转pdf Wkhtmltopdf
首先安装Wkhtmltopdfhttps://wkhtmltopdf.org/downloads.htmlwindows:下载这个,然后解压缩后就可以直接用。别忘加入PATH环境变量:然后打开cmd输入wkhtmltopdf http://www.baidu.com/ test.pdf能够成功转化即可!python脚本import pdfkitpath_wk = r'...原创 2019-12-03 10:40:08 · 238 阅读 · 0 评论 -
django 前后端分离跨域
INSTALLED_APPS = [ ... 'corsheaders', ...]MIDDLEWARE = [ ... 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', # 'django.middleware.c...原创 2019-11-26 17:15:02 · 198 阅读 · 0 评论 -
django使用redis
安装:pip install django-redis-sessions同时Windows下安装Redis服务https://www.cnblogs.com/phoebeyue/p/10231881.html修改settings文件增加如下项# 使用redis保存session数据 SESSION_ENGINE = 'redis_sessions.session' SESSI...原创 2019-11-26 17:14:11 · 169 阅读 · 0 评论 -
django项目部署时报错
1.报错:invalid PID numberreload时:(django_venv) [root@HostName-4chb03jf66500 sbin]# ./nginx -s reloadnginx: [error] invalid PID number “” in “/usr/local/nginx/logs/nginx.pid”切换到nginx目录:(django_venv)...原创 2019-09-02 08:24:49 · 267 阅读 · 0 评论 -
django-验证码-gvcode
1.安装gvcodepip install gvcode #全称为graphic-verification-code2.前端{#验证码图片#}<img id="code" src="data:image/jpeg;base64,{{ img }}" onclick="change_code(this)" />{#错误信息#}{{ error }}{#输入验证码的地方#...原创 2019-09-02 08:20:42 · 1133 阅读 · 2 评论 -
django-邮箱验证
settings.py# 邮件配置EMAIL_USE_SSL = FalseEMAIL_HOST = 'smtp.126.com' # 服务器EMAIL_PORT = 25EMAIL_HOST_USER = 'wwwccoomm@126.com' # 帐号EMAIL_HOST_PASSWORD = 'wujingyu0728' # 授权码(****)# 默认邮件DEFA...原创 2019-09-02 08:19:49 · 275 阅读 · 0 评论 -
pycharm连接mysql时报错
#在URL后加上:?serverTimezone=UTC&characterEncoding=utf-8原创 2019-09-02 08:28:25 · 158 阅读 · 0 评论 -
django-分页
后端def dongtai(request): context = {} dongtais = Article.objects.filter(sort=1).values('title', 'time', 'id') paginator = Paginator(dongtais, 7) num = paginator.num_pages context['...原创 2019-09-01 11:45:16 · 68 阅读 · 0 评论 -
django -前后端分离,ajax
1.直接在前端调用第三方的接口:三门峡今日天气:<span id="weather_1"></span>转<span id="weather_2"></span>,<span id="tmp_1"></span>°到<span id="tmp_2"></span>° </span>...原创 2019-09-01 11:44:41 · 406 阅读 · 0 评论 -
django定制后台
后台数据库显示对应app下的admin.pyfrom django.contrib import adminfrom article_app.models import Article # 引入数据模型引入APP的文章数据库,但是要具体定制就不用在这引入#admin.site.register(Article)后台登录进去的标题admin.site.site_header = '...原创 2019-09-01 11:43:34 · 187 阅读 · 0 评论 -
django网站实现全局搜索
1.相关包的安装pip install django-haystack whoosh jiebadjango-haystack:搜索框架whoosh:引擎jieba:中文分词2.setting中进行配置添加app,haystack必须在自己创建的app上面INSTALLED_APPS = [ 'django.contrib.admin', ... 'hays...原创 2019-09-01 11:42:17 · 1061 阅读 · 0 评论 -
RSA加密-django
1.安装Crypto2.生成公钥与私钥#将公钥与私钥写入settings.py文件中,一定注意格式不能变RAS加密秘钥RSA_PUBLIC_KEY = '''-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0VUm4Db5Rnvk35W+AqchafPBZ+ll3I3sFdsMGYo5NkD95W9pUh...原创 2019-09-01 11:39:53 · 600 阅读 · 1 评论 -
报错: cryptography is required for sha256_password or caching_sha2_password
实质为mysql的密码错误。原创 2019-09-01 11:38:58 · 2022 阅读 · 0 评论 -
报错:mysqlclient 1.3.3 or newer is required; you have 0.7.11
到python安装目录下C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Lib\site-packages\django\db\backends\mysql\base.py将if version < (1, 3, 3): raise ImproperlyConfigured("mysqlclient 1....原创 2019-09-01 11:38:26 · 518 阅读 · 0 评论 -
报错:No module named ‘widgets’的解决办法
DjangoUeditor是基于Python 2.7的,对Python3的支持有问题。导致widgets.py文件出错,不能import。采用网上修改好的版本DjangoUeditor3即可!https://github.com/twz915/DjangoUeditor3复制文件夹里面的DjangoUeditor文件夹,放到环境下的lib/site-packages/下C:\Users\xx...原创 2019-09-01 11:37:46 · 3115 阅读 · 0 评论 -
报错:'str' object has no attribute 'decode'
进入报错的文件夹operations.py,修改query = query.decode(errors=‘replace’)为query = query.encode(errors=‘replace’)原创 2019-09-01 11:35:37 · 341 阅读 · 0 评论 -
Django中使用富文本编辑器:Ueditor 详解
1.安装Ueditor包pip install DjangoUeditor2.配置settings.py加入appINSTALLED_APPS = [ 'django.contrib.admin', ... 'DjangoUeditor',]配置富文本编辑器的文件存放路径MEDIA_URL ='/media/'MEDIA_ROOT = os.path.j...原创 2019-09-01 11:34:57 · 660 阅读 · 0 评论