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

2021-07-11 04:04

阅读:900

标签: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


评论


亲,登录后才可以留言!