码迷,mamicode.com
首页 > Web开发 > 详细

关于 DjangoUeditor 上传图片图片失败,csrf token missing or incorrect 的解决办法

时间:2017-06-28 02:20:42      阅读:403      评论:0      收藏:0      [点我收藏+]

标签:settings   request   图片   pat   orb   tor   missing   ued   错误   

Forbidden (CSRF token missing or incorrect.): /ueditor/controller/
[27/Jun/2017 23:49:25] "POST /ueditor/controller/?imagePathFormat=courses%2Fueditor%2F&filePathFormat=courses%2Fueditor%2F&action=uploadvideo&encode=utf-8 HTTP/1.1" 403 2266

  错误原因:get_ueditor_controller() 方法没有csrf保护

  解决办法:

  在ueditor源码中的views.py文件中找到get_ueditor_controller函数,然后添加@csrf_exempt 装饰器

@csrf_exempt
def get_ueditor_controller(request):
    """获取ueditor的后端URL地址    """

    action=request.GET.get("action","")
    reponseAction={
        "config":get_ueditor_settings,
        "uploadimage":UploadFile,
        "uploadscrawl":UploadFile,
        "uploadvideo":UploadFile,
        "uploadfile":UploadFile,
        "catchimage":catcher_remote_image,
        "listimage":list_files,
        "listfile":list_files
    }
    return reponseAction[action](request)

 

关于 DjangoUeditor 上传图片图片失败,csrf token missing or incorrect 的解决办法

标签:settings   request   图片   pat   orb   tor   missing   ued   错误   

原文地址:http://www.cnblogs.com/justbreaking/p/7087864.html

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