Django-ckeditor文件上传不起作用 [英] Django-ckeditor file upload doesn't work

查看:130
本文介绍了Django-ckeditor文件上传不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的博客中使用django-ckeditor模块作为WYSIWYG编辑器来创建和编辑管理中的文章。它工作得很好,但我无法将图像上传到我的服务器。当我点击图像按钮时,按钮浏览服务器和上传图像不会按照它们应该出现(我在某处看到)。我只能添加外部图片提供他们的网址。
我使用Django 1.8与Python 3.4

I use django-ckeditor module in my blog as WYSIWYG editor for create and edit articles in the administration. It work pretty well but I can't upload image to my server. When I click on the image button, the button "browse the server" and "upload image" doesn't appear as they supposed to (I saw it somewhere). I can only add externals images providing their urls. I use Django 1.8 with Python 3.4

模块django-ckeditor和ckeditor_uploader已正确安装并添加到INSTALLED_APP中。

The module django-ckeditor and ckeditor_uploader are correctly installed and added in the INSTALLED_APP.

这是我的settings.py文件:

This is my settings.py file :

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'ckeditor',
    'ckeditor_uploader',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'django-mini-blog.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.media',
            ],
        },
    },
]

WSGI_APPLICATION = 'django-mini-blog.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

LANGUAGE_CODE = 'fr-fr'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

MEDIA_URL = '/media/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_IMAGE_BACKEND = "pillow"

提前感谢您的帮助。

真诚,

推荐答案

你添加了以下代码到您的urls.py文件?

Did you add the following code to your urls.py file?

    urlpatterns = patterns(
    '',
    ....
    (r'^ckeditor/', include('ckeditor.urls')),

)

这篇关于Django-ckeditor文件上传不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆