标签:obj one port att img rgs return ueditor pps
INSTALLED_APPS = [
‘DjangoUeditor‘
]
STATIC_URL = ‘/static/‘
MEDIA_ROOT = BASE_DIR + ‘/static/upload/upimg/‘
MEDIA_URL = ‘/static/upload/upimg/‘
STATICFILES_DIRS = [
‘static‘,
BASE_DIR + ‘/static/‘
]
from django.conf.urls import url,include
url(r‘^ueditor/‘, include(‘DjangoUeditor.urls‘)),
class ModuleInterDisplay(object):
style_fields = {"content": ‘ueditor‘}
def get_field_style(self, db_field, style, **kwargs):
if style in (‘ueditor‘,):
attrs = {‘widget‘: Ueditor} # 此处是顶部的widget引用
return attrs
五,建一个rte文件夹:里面包含__init__.py 和widgets.py,在widgets.py里放:
__author__=‘Administrator‘
#coding=utf-8
from django import forms
from django.conf import settings
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
class Ueditor(forms.Textarea):
def __init__(self, attrs={}):
super(Ueditor, self).__init__(attrs)
def render(self, name, value, attrs=None):
# rendered = super(Ueditor,self).render(name,value,attrs)
context = {
‘name‘: name,
‘STATIC_URL‘: settings.STATIC_URL,
‘value‘: value,
}
return mark_safe(render_to_string(‘widgets/ueditor.html‘, context))
标签:obj one port att img rgs return ueditor pps
原文地址:http://www.cnblogs.com/FYC8/p/7698589.html