In this recipe, we will take a look at the easiest way to handle image uploads. You will see an example of an app where the visitors can upload images with inspirational quotes.
Uploading images
Getting ready
Make sure you have Pillow installed. Either run the following command in your virtual environment, or update your requirements file accordingly and rebuild your Docker container:
(myproject_env)$ pip3 install Pillow~=5.2.0
Then, let's create a quotes app and put it in INSTALLED_APPS in the settings. For Docker projects, you will also need to add a volume mapping to your app container in docker-compose.yml.
Then, we will add an InspirationalQuote model with three fields: the author, quote, and picture, as follows...