django文件管理器的django cms插件
cmsplugin-filer的Python项目详细描述
一组替换django cms附带的插件的cms插件 使用django文件管理器中的文件字段的版本。
警告:
Starting with version 1.1.0, support for Python 2.6, Django 1.7 or lower and django CMS 3.0.x and lower was dropped. Please pin your dependencies to ``cmsplugin-filer<1.1.0`` for older projects. Starting with version 0.10 support for django CMS 2.x was dropped (table renaming magic removal). Pin your dependencies to ``cmsplugin-filer<0.10`` for django-cms 2.x projects.
依赖关系
- Django文件管理器=1.2
- django>;=1.8
- django cms>;=3.1
- Django Sekizai=0.4.2
- 简单缩略图>;=1.0
- django appconf
- djangocms属性字段
安装
开始使用cmsplugin-filer:
用pip:
安装$ pip install cmsplugin-filer
配置django-filer,如https://django-filer.readthedocs.io/en/latest/installation.html#configuration
将插件添加到INSTALLED_APPS:
INSTALLED_APPS = ( ... 'cmsplugin_filer_file', 'cmsplugin_filer_folder', 'cmsplugin_filer_link', 'cmsplugin_filer_image', 'cmsplugin_filer_teaser', 'cmsplugin_filer_video', ... )
运行migrate。
您还可以在settings.py中设置FILER_IMAGE_USE_ICON来配置 cmsplugin_filer_imageplugin使用32x32图标表示 插件实例。
cmsplugin_filer_image中的默认模板要求启用主题位置功能。 跟随:https://django-filer.readthedocs.io/en/latest/installation.html#subject-location-aware-cropping
升级到1.1版
在版本1.1中,有两个向后不兼容的更改:
迁移布局
迁移已移回标准位置。CMSPlugin_文件管理器相关 MIGRATION_MODULE设置项必须删除,cmsplugin_filer 1.1才能工作
删除ThumbnailOption模型
ThumbnailOption已移动到filer(从文件管理器1.2开始)。 您必须更新引用ThumbnailOption的模型和迁移才能正常工作。
升级过程包括更新模型和迁移。
型号.py
添加:
try: from filer.models import ThumbnailOption thumbnail_model = 'filer.ThumbnailOption' except ImportError: from cmsplugin_filer_image.models import ThumbnailOption thumbnail_model = 'cmsplugin_filer_image.ThumbnailOption'
如果使用字符串语法(例如:thumb_field = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption')) 使用上面定义的thumbnail_model字符串(例如:thumb_field = models.ForeignKey(thumbnail_model) 如果直接使用模型,则不必更改字段定义
django 1.7+迁移
对于每个引用ThumbnailOption的迁移文件,添加以下导入:
from myapp.models import thumbnail_model
并将所有'cmsplugin_filer_image.ThumbnailOption'更改为thumbnail_model
在每个迁移文件中添加以下导入:
from myapp.models import thumbnail_model
并将所有'cmsplugin_filer_image.ThumbnailOption'更改为thumbnail_model,然后 u"orm['cmsplugin_filer_image.ThumbnailOption']"到u"orm['%s']" % thumbnail_model。
cmsplugin_filer_image中的默认模板需要主题位置 要启用的功能。 跟随:http://django-filer.readthedocs.org/en/0.9.2/installation.html#subject-location-aware-cropping
请注意,当前开发版本将插件包从src 项目根目录。如果升级,可能会中断安装。 卸载以前的任何安装(从pypi或 并重新安装。
集成
djangocms-text-ckeditor
cmsplugin_filer_image提供与 djangocms-text-ckeditor。 添加此设置以启用它:
TEXT_SAVE_IMAGE_FUNCTION='cmsplugin_filer_image.integrations.ckeditor.create_image_plugin'
这允许在firefox和更新版本中将图像拖到文本编辑器中 即的。
定制
大多数插件(文件、文件夹、图像和摘要)支持配置自定义 “样式”(模板)。
例如,为图像插件添加以下设置:
CMSPLUGIN_FILER_IMAGE_STYLE_CHOICES = ( ('default', 'Default'), ('boxed', 'Boxed'), ) CMSPLUGIN_FILER_IMAGE_DEFAULT_STYLE = 'boxed'
现在,如果一个模板存在于^ {TT28 } $ 它将被使用。如果没有,它将返回到cmsplugin_filer_image/plugins/image/default.html。 如果默认模板中的css类足够多,则可以在 模板为{{ instance.style }}。
向后兼容性,如果存在的话,插件总是使用^ TT31 } $。去掉那个 迁移到新结构后的模板。
课程
像left、center、right和img-responsive这样的类是由插件提供的,用于您自己的项目中。