python-django ckeditor

修改ckeditor 的config.js 文件,添加上传图片功能:
    //config.width = 800;
    //config.height = 400;
    // Simplify the dialog windows.
    config.removeDialogTabs = 'image:advanced;link:advanced';
    var path = window.location;
    var url = path.pathname;
    config.filebrowserImageUploadUrl = url;


html文件,使用class类添加样式:
                          
也可以使用: CKEDITOR.replace('sec_bug_detail'); 获取ckeditor的文本内容: formdata["sec_bug_detail"] = CKEDITOR.instances.sec_bug_detail.getData(); django代码: if request.method == 'POST': #图片上传功能代码 callback = request.GET.get('CKEditorFuncNum') if callback: try: path = "static/upload/" + time.strftime("%Y%m%d%H%M%S",time.localtime()) f = request.FILES["upload"] file_name = path + "_" + f.name des_origin_f = open(file_name, "wb+") for chunk in f.chunks(): des_origin_f.write(chunk) des_origin_f.close() except Exception, e: raise Http404() res = "" return HttpResponse(res) #漏洞信息修改代码 if obj == "edit" and sec_bug_id != "" : data = {} result = bug_report_edit(data) return JsonResponse(result) return render_to_response("bug_edit.html",data)

你可能感兴趣的:(python-django ckeditor)