码迷,mamicode.com
首页 > 其他好文 > 详细

Django + xaadmin +Ueditor

时间:2017-10-20 13:28:09      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:obj   one   port   att   img   rgs   return   ueditor   pps   

 一,下载ueditorde js文件,放到static文件下,

  技术分享

二,配置setting,

INSTALLED_APPS = [
  ‘DjangoUeditor‘
]
STATIC_URL = ‘/static/‘
MEDIA_ROOT = BASE_DIR + ‘/static/upload/upimg/‘
MEDIA_URL = ‘/static/upload/upimg/‘
STATICFILES_DIRS = [
‘static‘,
BASE_DIR + ‘/static/‘

]

三,配置url

from django.conf.urls import url,include
url(r‘^ueditor/‘, include(‘DjangoUeditor.urls‘)),

四,在adminx.py里配置

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))






Django + xaadmin +Ueditor

标签:obj   one   port   att   img   rgs   return   ueditor   pps   

原文地址:http://www.cnblogs.com/FYC8/p/7698589.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!