Django Upload File

Simple upload file
os.path.join(BASE_DIR, 'myapp', 'templates')
myapp/templates/home.html
myapp/views.py
myapp/media
MEDIA_URL = '/media/' #newMEDIA_ROOT = os.path.join(BASE_DIR, 'myapp', 'media') #new
myapp/urls.py
myproject/urls.py
home
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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Invest In Blogging

WordPress & Pi: Setting Up Your Home Server

What about technology specific backlog management tools?

Get your Data Science environment ready in Ubuntu 20.04

WordPress…Developer?

Micro frontends: Hosting and independent deployments in a mono repo with Github Actions, AWS S3…

How To Promote a Growth Mindset in the Workplace

Push the Limits with Pandas

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adi Ramadhan

Adi Ramadhan

Software Engineer

More from Medium

Introduction to Django Framework

introduction to Django Framework

[Django] Django development notes (2) Templates

A Brief Intro: Python and Django

JAVA program to print “Hello, World!”

Handle MEDIA files in production — Django

floppy disks and Django media