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

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)

 

posted @ 2017-06-28 00:18  Justbreaking  阅读(1351)  评论(0编辑  收藏  举报