Uploading Images in Django with django-filer
Introduction (Don't really know what to write) Note django-filer currently only supports Django up to 1.11 setting.py INSTALLED_APPS = [ # image support 'easy_thumbnails', 'filer', 'mptt', ] # Image Upload Support THUMBNAIL_HIGH_RESOLUTION = Tr
目录3 个章节
Introduction
(Don't really know what to write)
Note
django-filer currently only supports Django up to 1.11
setting.py
INSTALLED_APPS = [
# image support
'easy_thumbnails',
'filer',
'mptt',
]
# Image Upload Support
THUMBNAIL_HIGH_RESOLUTION = True
THUNMNAIL_PROCESSORS = {
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'easy_thumbnails.processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
}
FILER_STORAGES = {
'public': {
'main': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(BASE_DIR, 'static/media/filer'),
'base_url': '/media/filer/'
},
'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
'UPLOAD_TO_PREFIX': 'filer_public'
},
'thumbnails': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(BASE_DIR, 'static/media/filer_thumbnails'),
'base_url': '/media/filer_thumbnails/',
}
}
},
'private': {
'main': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(BASE_DIR, 'static/smedia/filer'),
'base_url': '/smedia/filer/'
},
'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
'UPLOAD_TO_PREFIX': 'filer_public'
},
'thumbnails': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(BASE_DIR, 'static/smedia/filer_thumbnails'),
'base_url': '/smedia/filer_thumbnails/',
}
}
}
}
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/upload/media')
_EOF_
Uploading Images in Django with django-filer
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
Django解决跨域请求问题
几种方法 使用django-cors-headers全局控制**(推荐)** 使用JsonP,只能用于Get方法 在views.py里设置响应头,只能控制单个接口 django-cors-headers 首先安装 pip install django-cors-headers 然后在settings.py里配置一番就可以 INSTALLED_APPS = [ ... 'corshe
2022-08-26 · 0_Django基础知识 · 约 1 分钟
Django清空所有数据和重建表结构
清空所有数据 python manage.py flush 重建表结构 删除数据库中所有表 删除应用文件夹下的migrations目录内所有文件,除了__init__.py 执行以下命令 python manage.py makemigrations python manage.py migrate
2021-12-18 · 0_Django基础知识 · 约 1 分钟
Django应用中的静态文件处理
在日常开发中,我们都是把Django的Debug模式打开,方便调试,在这个模式下,由Django内置的Web服务器提供静态文件服务,不过需要进行一些配置,才能正确访问。 配置settings # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ ST
2021-12-18 · 0_Django基础知识 · 约 1 分钟
Django+Logging:日志记录配置与使用方法
前言 日志在程序开发中是少不了的,通过日志我们可以分析到错误在什么地方,有什么异常。在生产环境下有很大的用途。在Java开发中通常用log4j,logback等第三方组件。那么在django中是怎么处理日志?django利用的就是Python提供的logging模块,但django中要用logging,还得有一定的配置规则,需要在setting中设置。 Logging模块 Logging模块为应用
2022-04-02 · Django · 约 1 分钟
讨论
共 0 条加载评论中…