码迷,mamicode.com
首页 > 其他好文 > 详细

阿里云 centos 部署 Django 可能遇到的问题

时间:2019-11-13 13:27:14      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:inux   mac   errors   rem   strong   部署   路径   ror   enc   

问题一:版本限制  

File "/Users/icourt/Desktop/hf/venv/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 36, in <module>

    raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.‘ % Database.__version__)

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解决办法:跳转进上面路径文件注释掉版本判断

技术图片

问题二:  File "/Users/icourt/Desktop/hf/venv/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query

    query = query.decode(errors=‘replace‘)

AttributeError: ‘str‘ object has no attribute ‘decode‘

解决办法:跳转上面文件路径将decode更换为encode

技术图片

问题三:set_cookie为中文,需转码

    self.status.split(‘ ‘,1)[0], self.bytes_sent

AttributeError: ‘NoneType‘ object has no attribute ‘split‘

解决办法:dumps / loads 用法

import json
  username=‘用户1‘
  username=json.dumps(username)
  username="\\u7528\\u62371"
# 反序列化
username=json.loads(username)
username=‘用户1‘

在Django中:

                if remember==‘on‘:
                    # 记住用户名
                    # 如果username是中文,设置cookies时会报错
                    # cookie 中文编码处理
                    username=json.dumps(username)
                    response.set_cookie(‘username‘,username,max_age=7*24*3600)

else:
                    # 取消记住用户名
                    response.delete_cookie(‘username‘)

        if ‘username‘ in request.COOKIES:
            username=request.COOKIES.get(‘username‘)
            username=json.loads(username)

问题四:nginx: [emerg] unknown directive "location/" in /usr/local/nginx/conf/nginx.conf:24

解决办法:看看是不是有中文空格。。。

问题五:初始化实例后,Mac和Linux远程连接服务器异常修复(WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!)

解决办法:

  1. 根据提示找到.ssh/known_hosts结尾文件路径

 技术图片

  1.  vim 编辑该文件,删除原有的ssl

技术图片

  1. 再次连接即可

阿里云 centos 部署 Django 可能遇到的问题

标签:inux   mac   errors   rem   strong   部署   路径   ror   enc   

原文地址:https://www.cnblogs.com/feizisy/p/11847996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!