Django: Getting Started Transcripts
Chapter: Receiving Uploads in Django
Lecture: Uploading images using forms

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Up until now, you've been dealing with text data submitted via a form. Even your numeric data has technically been text data.
0:07 When you submit the review rating field to the server in a form, it is sent as text. The Django model form knows the field types of the
0:15 Associated Model so it automatically converts the text sent by the browser into the appropriate storage type, like an integer between 1 and 5.
0:25 Forms can also send files which includes a way of sending binary data like images. Django calls these uploads media files,
0:33 they are handled separately from a view page or static files.
0:39 To use media files, first off, you need to configure your system to tell Django where to put these uploaded files
0:44 and of course you need a directory to put them in. It is recommended that this be outside of your code base.
0:50 This allows you to do things like set your code is read only on the server so if someone malicious gets in it limits the damage.
0:58 There are model fields that can point to media files and a very commonly used one is the image field, which expects an uploaded file to be an image.
1:08 The only caveat with this is it requires a third party image processing library called Pillow.

Talk Python's Mastodon Michael Kennedy's Mastodon