tutorial_test增加django_debug插件
pip install django-debug-toolbar -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
其他的部分直接按官网的操作install搞定
增加easy-thumbnails
pip install easy-thumbnails -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
大概搞清楚了这个工具的价值:
对于media中的图片做处理,可以是裁剪、改分辨率,格式等等。
maybe 在cache中也能做一点处理,提高performance!
尝试另外一个插件:django-filer
简单地试了一下,确实很好用的样子!一个在django admin下面的文档管理器
pip install django-polymorphic django-mptt django-filer -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
目前是django-cms给钱的一个开源工具!
使用起来还是很有价值,也比较的简单! 中间出现的一个bug是chatgpt给错了解释!
依赖包有三个:easy-thumbnails、django-polymorphic、django-mptt
settings里面要改的若干项目:
INSTALLED_APPS
'easy_thumbnails',
'filer',
'mptt',
其他的部位
INTERNAL_IPS = [
# ...
"127.0.0.1",
# ...
]
THUMBNAIL_STORAGE = 'easy_thumbnails.filesystems.FileSystemStorage'
THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_ALIASES = {
'': {
'small': {'size': (200, 200), 'crop': True}, # 200x200 裁剪缩略图
'medium': {'size': (400, 400), 'crop': True}, # 400x400
'large': {'size': (800, 800), 'crop': False}, # 800x800,不裁剪
},
}
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
)
in models.py
file = FilerFileField(
related_name='documents',
on_delete=models.CASCADE,
blank=True,
null=True,
verbose_name="文件"
)
in admin.py
admin.site.register(Document, DocumentAdmin)
admin.site.unregister(File)
admin.site.register(File, FileAdmin)
重点:作为一个独立的工具,它自己带了若干个tables。也就是说它本质上是可以无model运行的。
它自己这样子带了7个表,7个表对于文件的管理就已经做了很多的控制!
filer_clipboard
filer_clipboarditem
filer_file
filer_folder
filer_folderpermission
filer_image
filer_thumbnailoption
实际的使用则是自己的model去foreignkey这九个tables。所以逻辑上改动的地方其实不多。
开始的Bug是在settings.py之中做了错误的配置:
FILER_FILE_MODELS = { 'file': 'filer.File', # 默认的文件模型 }
help里面几乎没有这个参数的设置。最后想着把这个code 删掉,就一切正常了。用起来算是一个有我需要的功能的工具!说是sha1都嵌入在里面了!所以可以处理duplicate,但是同样的文档可以上传两次!maybe 要在什么地方设置unique=true才行!
问题是这个工具的用户数量可能不是特别多,虽然github里面有1.8k star,从数量上看是很不少,但是在google中可以搜索到的配置应用的article不多!
另外就是它的help做得太潦草了。从help里面难get到足够多准确的idea!
但是确实是用起来很舒服的一个工具。可以算是今天的收货了!
问题是给user 做update效果不好,或者是暂时没搞清楚它的source code!
其他若干个需要尝试的add on
2. django-allauth
3. django-filer
4. django-ckeditor
5. django-comments
6. django-crispy-forms
7. django-tagging
8. django-activities
9. django-simple-history
10. django-celery
11. django-searchable-select
12. django-storages
13. django-reversion
14. django-filter
15. django-notifications-hq
16. django-user-accounts
n5321 | 2025年2月15日 22:28