ueditor用法

settings裏設置好media_root後端

import os
HERE = os.path.dirname(os.path.dirname(__file__))

MEDIA_ROOT = os.path.join(HERE, "media").replace('\\', '/')

MEDIA_URL = "/site_media/"url

 

models裏面使用字段圖片

content = UEditorField(u"內容", imagePath="uploadimg/",blank=True, null=True)it

 

urls裏面加入import

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)配置

 

例如:ueditor

urlpatterns = patterns('',
                       url(r'^xadmin/', include(xadmin.site.urls), name='xadmin'),
                       url(r'^ueditor/', include('DjangoUeditor.urls' )),
                       )
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)file

 

這樣就能夠避免後端配置不正確,不能上傳圖片。model

相關文章
相關標籤/搜索