ImageField and Serving Uploads
Handle images and link to media in dev.
Why ImageField
For pictures, use ImageField instead of FileField. It works the same but adds image-specific checks and helpers on top.
avatar = models.ImageField(upload_to='avatars/')Pillow Is Required
ImageField depends on the Pillow library to read images. Install it first or migrations will refuse to run. 🖼️
pip install PillowAll lessons in this course
- STATICFILES and the static Tag
- collectstatic for Production
- MEDIA_ROOT and File Uploads
- ImageField and Serving Uploads