In this video we'll see how to handle user uploads and media files in a Django project. We'll see how to use Django model ImageField and FileField to store relative paths to files on the file-system, and will see how to create a Django Form class that allows users to upload files.
We'll see what the MEDIA_ROOT and MEDIA_URL settings are for, and how Django can serve media files during development.
Finally, we'll also see how to delete files from the filesystem when the underlying row in the database is deleted, and will discuss the default behaviour of Django in this case.
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:21 Django ImageField and FileField model fields
03:39 Adding Django model with an ImageField
05:27 Adding ModelForm for image uploads
10:10 Handling POST request in view with uploaded file
13:40 Database representation of Django FileField and ImageField
14:25 Creating List view for all uploaded files
17:42 Serving media files with Django
19:33 Changing ImageField upload_to parameter
20:38 Django ImageField additional properties
21:29 Adding delete button to list-view card
26:20 django-cleanup for deleting files attached to model classes
25:52 Overriding the Django model delete method
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
[ Ссылка ]
▶️ Full Playlist:
[ Ссылка ]
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: [ Ссылка ]
👾 Github: [ Ссылка ]
🐦 Twitter: [ Ссылка ]
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Managing Files in Django: [ Ссылка ]
How to manage static files in Django: [ Ссылка ]
TailwindCSS Cards: [ Ссылка ]
Tailwind Form Styling: [ Ссылка ]
Tailwind File Input styling: [ Ссылка ]
Django-cleanup: [ Ссылка ]
Overriding pre-defined Django model methods: [ Ссылка ]
#python #django #mediafile
Ещё видео!