Django Media Files - Handling User Uploads in Django Forms & Models

Описание к видео Django Media Files - Handling User Uploads in Django Forms & Models

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:
https://ko-fi.com/bugbytes

▶️ Full Playlist:
   • Django Media Files  

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: https://bugbytes.io/posts/
👾 Github: https://github.com/bugbytes-io/
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Managing Files in Django: https://docs.djangoproject.com/en/4.1...
How to manage static files in Django: https://docs.djangoproject.com/en/4.1...
TailwindCSS Cards: https://v1.tailwindcss.com/components...
Tailwind Form Styling: https://v1.tailwindcss.com/components...
Tailwind File Input styling: https://flowbite.com/docs/forms/file-...
Django-cleanup: https://pypi.org/project/django-cleanup/
Overriding pre-defined Django model methods: https://docs.djangoproject.com/en/4.1...

#python #django #mediafile

Комментарии

Информация по комментариям в разработке