我有一个关于 django cms 2.3.3的本地安装的问题:我已经通过pip安装它,在一个单独的virtualenv中.接下来我按照settings.py配置教程,启动了服务器.然后在管理员我创建了一个页面(主页),我试图通过cmsplugin_filer_image在占位符中添加一个图像,但上传似乎不起作用.这是我的settings.py:
# Django settings for cms1 project.
# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name','your_email@example.com'),)

MANAGERS = ADMINS

DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',# Add 'postgresql_psycopg2','MysqL','sqlite3' or 'oracle'.
    'NAME': 'cms1',# Or path to database file if using sqlite3.
    'USER': 'cms',# Not used with sqlite3.
    'PASSWORD': 'cms',# Not used with sqlite3.
    'HOST': '',# Set to empty string for localhost. Not used with sqlite3.
    'PORT': '',# Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Rome'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'it-it'

SITE_ID = 1

# If you set this to False,Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False,Django will not format dates,numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False,Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.laWrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_PATH,"media")

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.laWrence.com/media/","http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_Dirs.
# Example: "/home/media/media.laWrence.com/static/"
STATIC_ROOT = os.path.join(PROJECT_PATH,"static")
STATIC_URL = "/static/"


# Additional locations of static files
STATICFILES_Dirs = (
     os.path.join(PROJECT_PATH,"static_auto"),# Put strings here,like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes,even on Windows.
    # Don't forget to use absolute paths,not relative paths.
)

# List of finder classes that kNow how to find static files in
# varIoUs locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder','django.contrib.staticfiles.finders.AppDirectoriesFinder',#    'django.contrib.staticfiles.finders.DefaultStorageFinder',)

# Make this unique,and don't share it with anybody.
SECRET_KEY = '^c2q3d8w)f#gk%5i)(#i*lwt%lm-!2=(*1d!1cf+rg&-hqi_9u'

# List of callables that kNow how to import templates from varIoUs sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader','django.template.loaders.app_directories.Loader',#     'django.template.loaders.eggs.Loader',)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','cms.middleware.multilingual.MultilingualURLMiddleware','cms.middleware.page.CurrentPageMiddleware','cms.middleware.user.CurrentUserMiddleware','cms.middleware.toolbar.ToolbarMiddleware',# Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',)

ROOT_URLconf = 'cms1.urls'

# Python dotted path to the Wsgi application used by Django's runserver.
Wsgi_APPLICATION = 'cms1.wsgi.application'

TEMPLATE_Dirs = (
    os.path.join(PROJECT_PATH,"templates"),like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes,not relative paths.
)

CMS_TEMPLATES = (
    ('template_1.html','Template One'),('template_2.html','Template Two'),)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth','django.core.context_processors.i18n','django.core.context_processors.request','django.core.context_processors.media','django.core.context_processors.static','cms.context_processors.media','sekizai.context_processors.sekizai',)

LANGUAGES = [
    ('it','Italiano'),('en','English'),]

INSTALLED_APPS = (
    'django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.sites','django.contrib.messages','django.contrib.staticfiles','cms',#django CMS itself
    'mptt',#utilities for implementing a modified pre-order traversal tree
    'menus',#helper for model independent hierarchical website navigation
    'south',#intelligent schema and data migrations
    'sekizai',#for javascript and css management
    #'cms.plugins.file','cms.plugins.flash','cms.plugins.googlemap','cms.plugins.link',#'cms.plugins.picture','cms.plugins.snippet','cms.plugins.teaser','cms.plugins.text',#'cms.plugins.video','cms.plugins.twitter','filer','cmsplugin_filer_file','cmsplugin_filer_folder','cmsplugin_filer_image','cmsplugin_filer_teaser','cmsplugin_filer_video','easy_thumbnails','PIL',# Uncomment the next line to enable the admin:
    'django.contrib.admin',# Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,'disable_existing_loggers': False,'filters': {
    'require_debug_false': {
        '()': 'django.utils.log.requiredebugFalse'
    }
    },'handlers': {
    'mail_admins': {
        'level': 'ERROR','filters': ['require_debug_false'],'class': 'django.utils.log.AdminemailHandler'
    }
    },'loggers': {
    'django.request': {
        'handlers': ['mail_admins'],'level': 'ERROR','propagate': True,},}
}

当我尝试上传图片时,在剪贴板部分我没有缩略图,只是一个“未定义”的消息:

这是尝试上传时的runserver控制台:

[20/Oct/2012 15:15:56] "POST /admin/filer/clipboard/operations/upload/?qqfile=29708_1306856312320_7706073_n.jpg HTTP/1.1" 500 248133
[20/Oct/2012 15:15:56] "GET /it/admin/filer/folder/unfiled_images/undefined HTTP/1.1" 301 0
[20/Oct/2012 15:15:56] "GET /it/admin/filer/folder/unfiled_images/undefined/ HTTP/1.1" 404 1739

此外,这是项目文件系统:

cms1
├── cms1
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── media
│ │ └── filer_public
│ │     └── 2012
│ │         └── 10
│ │             └── 20
│ │                 ├── 29708_1306856312320_7706073_n_1.jpg
│ │                 ├── 29708_1306856312320_7706073_n_2.jpg
│ │                 ├── 29708_1306856312320_7706073_n_3.jpg
│ │                 ├── 29708_1306856312320_7706073_n_4.jpg
│ │                 ├── 29708_1306856312320_7706073_n_5.jpg
│ │                 ├── 29708_1306856312320_7706073_n_6.jpg
│ │                 ├── 29708_1306856312320_7706073_n_7.jpg
│ │                 ├── 29708_1306856312320_7706073_n.jpg
│ │                 └── torrent-client-macosx.jpg
│ ├── settings.py
│ ├── settings.pyc
│ ├── static
│ ├── static_auto
│ ├── static_manual
│ ├── templates
│ │ ├── base.html
│ │ ├── template_1.html
│ │ └── template_2.html
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
└── manage.py

因此上传文件,但cms无法访问它们.这里有一个similar question,但对我这么帮助.
对我这个问题的任何帮助都会非常有帮助.

谢谢,卢克

解决方法

此错误是因为您安装了PIL而没有JPEG / PNG支持.
您需要安装以下软件包
sudo apt-get install python-imaging  python-dev libjpeg8 libjpeg8-dev libfreetype6 libfreetype6-dev

然后卸载PIL pip卸载PIL

我建议使用pip安装枕头安装枕头代替PIL.确保在安装后阅读日志,应该说支持JPEG和PNG

python – Django CMS – 无法通过cmsplugin_filer_image上传图像的更多相关文章

  1. XCode 3.2 Ruby和Python模板

    在xcode3.2下,我的ObjectiveCPython/Ruby项目仍然可以打开更新和编译,但是你无法创建新项目.鉴于xcode3.2中缺少ruby和python的所有痕迹(即创建项目并添加新的ruby/python文件),是否有一种简单的方法可以再次安装模板?我发现了一些关于将它们复制到某个文件夹的信息,但我似乎无法让它工作,我怀疑文件夹的位置已经改变为3.2.解决方法3.2中的应用程序模板

  2. Swift基本使用-函数和闭包(三)

    声明函数和其他脚本语言有相似的地方,比较明显的地方是声明函数的关键字swift也出现了Python中的组元,可以通过一个组元返回多个值。传递可变参数,函数以数组的形式获取参数swift中函数可以嵌套,被嵌套的函数可以访问外部函数的变量。可以通过函数的潜逃来重构过长或者太复杂的函数。

  3. Swift:实例方法和类型方法

    大家对“实例方法和类型方法”的概念应该不陌生了,在objective-c中很常见。例如:1.实例方法调用的时候,必须先进行实例化一个对象,然后调用init方法。而在Swift中写法有所改变,它使用class和static关键字来标示。

  4. 10 个Python中Pip的使用技巧分享

    众所周知,pip 可以安装、更新、卸载 Python 的第三方库,非常方便。本文小编为大家总结了Python中Pip的使用技巧,需要的可以参考一下

  5. Swift开发必备技巧:static和class的使用

    Swift中表示“类型范围作用域”这一概念有两个不同的关键字,它们分别是static和class。但是在Swift中,这两个关键字却是不能用混的。在非class的类型上下文中,我们统一使用static来描述类型作用域。这包括在enum和struct中表述类型方法和类型属性时。static适用的场景有这些:enum的情况与这个十分类似,就不再列举了。在Swift中class、struct和enum都是可以实现protocol的。

  6. OC和Swift中的static

    在非class的类型上下文中,我们统一使用static来描述类型作用域,class关键字是专门用在class类型的上下文中的,可以用来修饰类方法以及类的计算属性。Swift1.2之后,类也可以通过static关键字拥有类型存储属性了,static相当于classfinal标识符的别名,类中的static属性拥有全局作用域和懒加载属性。

  7. swift的静态属性(方法)和java的不同

    swift在任何情况下静态属性都要加上类名做为前缀,在java中通过实例名使用静态属性是一个warning,在swift中这里是一个错误swift中的static属性===swift中的finalclass====java中的finalstaticswift多出了class属性这个概念,用来表示`可以被子类重写的static属性`,然并卵,我觉得不如直接使用static和finalstatic,少一种概念swift中子类不能覆盖父类的storedproperty,但是可以覆盖父类的computedprop

  8. Swift、Go、Julia与R能否挑战 Python 的王者地位

    本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请发送邮件至dio@foxmail.com举报,一经查实,本站将立刻删除。

  9. JokeClient-Swift 仿写学习

    STATIC和CLASSSwift中表示“类型范围作用域”这一概念有两个不同的关键字,它们分别是static和class。在Swift中class,struct和enum都是可以实现某个protocol的。在Swift中编译器不仅不会对AnyObject实例的方法调用做出检查,甚至对于AnyObject的所有方法调用都会返回Optional的结果。摘自:ANY和ANYOBJECTSELECTOR在Swift中没有@selector了,取而代之,从Swift2.2开始我们使用#selector来从暴露给Ob

  10. Swift 学习笔记 [2] 类 结构体 枚举

    错误处理四种错误处理方法传播给调用该函数的代码funcprocesFn()throwtryprocessFn()docatch捕获do{tryexpression}catchpattern1{}catchpattern2{}将错误转成可选值funcprocessFn()throw->Int{}lettry?processFn()defer定义:defer定义的函数内,在此函数完成后,立即再次调用defer定义的代码块。无关的话学了还是要用,第一版Swift文档出来的时候,还凑热闹学了一次,现在都忘得差不多

随机推荐

  1. 10 个Python中Pip的使用技巧分享

    众所周知,pip 可以安装、更新、卸载 Python 的第三方库,非常方便。本文小编为大家总结了Python中Pip的使用技巧,需要的可以参考一下

  2. python数学建模之三大模型与十大常用算法详情

    这篇文章主要介绍了python数学建模之三大模型与十大常用算法详情,文章围绕主题展开详细的内容介绍,具有一定的参考价值,感想取得小伙伴可以参考一下

  3. Python爬取奶茶店数据分析哪家最好喝以及性价比

    这篇文章主要介绍了用Python告诉你奶茶哪家最好喝性价比最高,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习吧

  4. 使用pyinstaller打包.exe文件的详细教程

    PyInstaller是一个跨平台的Python应用打包工具,能够把 Python 脚本及其所在的 Python 解释器打包成可执行文件,下面这篇文章主要给大家介绍了关于使用pyinstaller打包.exe文件的相关资料,需要的朋友可以参考下

  5. 基于Python实现射击小游戏的制作

    这篇文章主要介绍了如何利用Python制作一个自己专属的第一人称射击小游戏,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起动手试一试

  6. Python list append方法之给列表追加元素

    这篇文章主要介绍了Python list append方法如何给列表追加元素,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

  7. Pytest+Request+Allure+Jenkins实现接口自动化

    这篇文章介绍了Pytest+Request+Allure+Jenkins实现接口自动化的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  8. 利用python实现简单的情感分析实例教程

    商品评论挖掘、电影推荐、股市预测……情感分析大有用武之地,下面这篇文章主要给大家介绍了关于利用python实现简单的情感分析的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下

  9. 利用Python上传日志并监控告警的方法详解

    这篇文章将详细为大家介绍如何通过阿里云日志服务搭建一套通过Python上传日志、配置日志告警的监控服务,感兴趣的小伙伴可以了解一下

  10. Pycharm中运行程序在Python console中执行,不是直接Run问题

    这篇文章主要介绍了Pycharm中运行程序在Python console中执行,不是直接Run问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

返回
顶部