-1

我用ImageField(). 但是每当我运行python manage.py它时,它都会说您需要安装pillow.ERRORS

sho.Product.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "python -m pip
install Pillow".
4

3 回答 3

0

它确实告诉了您如何修复它,您没有安装枕头库,因此除非您运行,否则图像字段将无法工作python -m pip install Pillow。运行命令即可解决问题

于 2020-06-24T12:24:22.673 回答
0

我认为您使用的是旧版本的 Django 旧版本不支持 ImageField() 而不安装枕头。只需通过运行以下命令来更新 Django 包

you must do the following:
1- Update pip
python -m pip install --upgrade pip
2- If you already install Django update by using the following command
pip install --upgrade Django
or you can uninstall it using the following command
pip uninstall Django
3- If you don't install it yet use the following command
python -m pip install Django
4- Type your code

Enjoy
于 2020-06-24T20:38:22.803 回答
-1

安装枕头库, pip install Pillow

在你的 models.py 导入枕头如下

from PIL import Image
于 2020-06-24T12:19:02.270 回答