3.找到專案urls檔案,配置djangoueditor路由
from djangoueditor.models import ueditorfield
content=ueditorfield(verbose_name='部落格內容',
width=700,
height=400,
*******s='full',
imagepath='ueditor/images/',
filepath='ueditor/files/',
upload_settings=,
default='')
5.xadmin中新增外掛程式ueditor
import xadmin
from xadmin.views import baseadminplugin, createadminview, modelformadminview, updateadminview
from djangoueditor.models import ueditorfield
from djangoueditor.widgets import ueditorwidget
from django.conf import settings
class xadminueditorwidget(ueditorwidget):
def __init__(self,**kwargs):
self.ueditor_options=kwargs
self.media.js = none
super(xadminueditorwidget,self).__init__(kwargs)
class ueditorplugin(baseadminplugin):
def get_field_style(self, attrs, db_field, style, **kwargs):
if style == 'ueditor':
if isinstance(db_field, ueditorfield):
widget = db_field.formfield().widget
param = {}
param.update(widget.ueditor_settings)
param.update(widget.attrs)
return
return attrs
def block_extrahead(self, context, nodes):
js = '' % (settings.static_url + "ueditor/ueditor.config.js") #自己的靜態目錄
js += '' % (settings.static_url + "ueditor/ueditor.all.min.js") #自己的靜態目錄
xadmin.site.register_plugin(ueditorplugin, updateadminview)
xadmin.site.register_plugin(ueditorplugin, createadminview)
6.將ueditor外掛程式新增到plugins中的__init__.py的plugins中
8.配置上傳檔案的載入路徑
1.在settings裡面配置
media_url='/media/'
media_root=os.path.join(base_dir,'media')
在settings裡面配置
from django.views.static import serve
在urls裡面配置
url(r'^media/(?p.*)$',serve,,name='media')
django xadmin後台管理
1 xadmin 後台管理比django 自帶admin好用多了,介面更好看。2 xadmin該怎樣安裝呢?github 然後用pip install c users luguanyou desktop xadmin.zip 後面是檔案路徑 安裝完後,解壓後可以看到xadmin檔案,把它拷貝到專案根...
django xadmin管理後台
在解壓的檔案裡requirements.txt有列出相關的依賴包,用pip安裝 找到base dir這行,修改前 如下 修改後的 如下 setting.py設定成中文 urls.py中配置路由 執行 makemigrations 和migrate,然後runserver啟動服務 python man...
Django xadmin安裝最詳細
django.contrib.admin django.contrib.auth django.contrib.contenttypes django.contrib.sessions django.contrib.messages django.contrib.staticfiles xadmin...