Why can't I upload jpg files to my Django app via admin/?

后端 未结 9 1958
借酒劲吻你
借酒劲吻你 2020-12-16 14:16

I\'m trying to add images to my models in my Django app.

models.py

class ImageMain(models.Model):
  product = models.ForeignKey(Product)
  photo = mo         


        
9条回答
  •  孤城傲影
    2020-12-16 14:27

    I met the same problem in Ubuntu server, then you can fix it by installing libjpeg-dev before PIL.

    sudo apt-get install libjpeg-dev
    sudo pip install PIL --upgrade
    

    and if you already installed libjpeg-dev after PIL. then you can remove PIL first, and try to reinstall PIL as following.

    sudo pip uninstall PIL
    sudo apt-get install libjpeg-dev
    sudo pip install PIL
    

    It works for me, and hope it works for you.

提交回复
热议问题