Django 使用UEditor
来源:互联网 发布:iapp源码大全下载2017 编辑:程序博客网 时间:2024/05/29 09:26
Django package 的一些包不支持upload file, 并且 有几个支持的不是收费的就是要开csrf ,这对于苦逼程序员来说始终是件恼火的事,所以经过查阅各种资料,看了各种各样的配置doc, 终于搞定了django + Ueditor (开源,含upload file 功能的组件)下面粗略写了些步骤:
1. your html page<head><!--FOR UEDITOR --><script type="text/javascript" charset="utf-8"> window.UEDITOR_HOME_URL = window.UEDITOR_HOME_URL||"/Ueditor/ueditor/";</script><script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor/editor_config.js"></script><script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor/editor_all_min.js"></script><link rel="stylesheet" type="text/css" href="/static/Ueditor/ueditor/themes/default/ueditor.css"/><!--FOR UEDITOR --></head><form> <p> <label>提案内容</label> <textarea class="text-input textarea" id="proposal_content" name="proposal_content" cols="79" rows="15"></textarea> </p> <p></form>after form <!-- for ueditor--> <script type="text/javascript"> var ue=new UE.ui.Editor(); ue.render('proposal_content'); </script> <!--for ueditor-->2.in uedior.views:
#coding:utf-8from proposal_platform import settings #using your project root settings from django.core.context_processors import csrffrom django.http import HttpResponse, HttpResponseRedirectfrom django.shortcuts import render_to_responsefrom django.template.context import RequestContextfrom django.views.decorators.csrf import csrf_exemptfrom PIL import Image # help to create uplaoded bitmap import base64import osimport timeimport urllib2import uuidfrom django.utils.encoding import smart_unicode3.urlconfig:( # for UEditor {{ url(r'^ueditor_imgup$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_ImgUp'), url(r'^ueditor_fileup$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_FileUp'), url(r'^ueditor_getRemoteImage$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_getRemoteImage'), url(r'^ueditor_scrawlUp$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_ScrawUp'), url(r'^ueditor_getMovie$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_getMovie'), url(r'^ueditor_imageManager$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_imageManager'), # }} # 这里是否使用/admin/aaa.html的请求 ,如果有静态网页的请求要在里面单独设计 {{ url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}), url(r'^(?!admin)(?P<path>.*)$','django.views.static.serve', {'document_root': settings.STATIC_ROOT}), url(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.ADMIN_HTML_ROOT}), # }})if settings.DEBUG is False: urlpatterns += patterns('', url(r'^static/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': settings.STATIC_ROOT }), )
4.the full dir of the project:
0 0
- Django 使用UEditor
- Django使用Ueditor
- django 在admin中使用ueditor
- 在django xadmin中使用 Ueditor
- 在django中使用ueditor插件
- django 在admin中使用ueditor
- Django 配置 Ueditor
- 使用Ueditor
- ueditor使用
- UEditor使用
- ueditor 使用
- 使用UEditor
- Ueditor 使用
- 使用UEditor
- ueditor使用
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- 一个”叫床“软件的需求分析及其软件架构设计
- 软工文档 “旅行记”
- ubuntu 12.10中MyEclipse 10.6+下载+安装+破解
- 10.四位共阴数码管实验
- 我用HTML写的新学期课程表
- Django 使用UEditor
- 发送广播的两种方式
- Java学习 第三章面向对象 (下)
- 杭电OJ 1106:排序
- 第一周(项目2)——胖子伤不起!
- 封装代码和UI的利器—Fragment(一)
- 爱情是什么样子
- Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (三) —— SharePreferences
- USACO 4.1 Beef McNuggets (nuggets)