目录
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
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看不到项目

解决办法:
- 第一种方法:点击
file->Settings->Project->Project structure然后把邮编Excluded红色的Excluded Folders目录给删掉就好了~ - 第二种方法:按
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',
]
掉头一去是风吹黑发,回首再来已雪满白发。

本文档详细介绍了Django开发过程中常见的几个问题及其解决方案,包括启动时报错、迁移时报错、WSGI配置错误、PyCharm无法加载项目以及解决跨域问题的具体实现。

2025

被折叠的 条评论
为什么被折叠?



