0Pricing
Django Academy · Lesson

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 Pillow

All lessons in this course

  1. STATICFILES and the static Tag
  2. collectstatic for Production
  3. MEDIA_ROOT and File Uploads
  4. ImageField and Serving Uploads
← Back to Django Academy