返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
0_Django基础知识

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

曦远 (DealiAxy)约 5 分钟
目录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+Logging:日志记录配置与使用方法

前言 日志在程序开发中是少不了的,通过日志我们可以分析到错误在什么地方,有什么异常。在生产环境下有很大的用途。在Java开发中通常用log4j,logback等第三方组件。那么在django中是怎么处理日志?django利用的就是Python提供的logging模块,但django中要用logging,还得有一定的配置规则,需要在setting中设置。 Logging模块 Logging模块为应用

2022-04-02 · Django · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…