Django图片上传与读取完全攻略!!
准备工作
Django版本:2.2~3.1
数据库模型字段直接使用 ImageField
使用ImageField必须要安装第三方库Pillow
settings.py的配置(顶级settings)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.