django报错汇总

目录

django启动报:'str' object has no attribute 'decode'

django迁移报index column size too large. the maximum column size is 767 bytes

cWSGI application 'c.wsgi.application' could not be loaded; Error importing

pucharm看不到项目

django中间件解决跨域问题-No 'Access-Control-Allow-Origin'

 


django启动报:'str' object has no attribute 'decode'

解决: 146行将将decode修改成encode

 

django迁移报index column size too large. the maximum column size is 767 bytes

发生这个错误实在mysql5.6下,我报错是发生在迁移的时候,具体解决请参考我的另外一篇文章:mysql报 index column size too large. the maximum column size is 767 bytes错误解决

 

cWSGI application 'c.wsgi.application' could not be loaded; Error importing

解决: 这个是setting中WSGI_APPLICATION配置和项目中uwsgi文件有误

 

pucharm看不到项目

解决办法: 

  1. 第一种方法:点击file->Settings->Project->Project structure 然后把邮编Excluded红色的Excluded Folders目录给删掉就好了~
  2. 第二种方法:按project->mark directory as->cancel exclusion 就可以了

django中间件解决跨域问题-No 'Access-Control-Allow-Origin'

现象

解决方法

在app下创建一个middlewares.py文件,写入如下代码:

from django.utils.deprecation import MiddlewareMixin
class MWObj(MiddlewareMixin):
    def process_response(self, request, response):
        response['Access-Control-Allow-Origin'] = "*"
        return response

然后注册

MIDDLEWARE = [
    ... ...
    'app.xx.middlewares.MWObj',
]

 

掉头一去是风吹黑发,回首再来已雪满白发。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

木子林_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值