Simple Django upload file
Official doc here.

Simple upload file

Step 1: Preparation, Create Django Project, Initial Migration
create virtualenv: virtualenv venv
start virtualenv: venv/Scripts/activate
install Django in virtualenv: pip install django==3.0
Create Django: django-admin startproject myproject
Go to myproject folder: cd myproject
Initial Migration: python migrate

Step 2: Create Django Apps
Create apps: python startapp myapp
Add myapp to INSTALLED_APPS in myproject/

Step 3: Set up Templates Folder
Create folder templates in myapp

Add template directory in TEMPLATES parameter in myproject/

Step 5: Create HTML Files in myapp/templates Folder
create home.html


Step 6: Create Function in
create home method in


Step 7: Setup Media Folder
create myapp/media folder


set media url and media root in

Step 8: Setup URLs in myapp and myproject Folder
Create myapp/


Update myproject/


Step 9: Run Server and Testing
Run Server: python runserver

upload file
upload file success
uploaded file to media folder
File access via url (for image file will be show in folder, some format will be auto-downloaded)

Software Engineer