From the course: Django: Forms
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Forms and files
- A very great feature of forms that we have not discussed yet is the ability to take files that the user wants to upload to us, whether it's going to be images or some sort of CSV data. Whatever it is, we can accept that into our project via forms. If you're going to accept some sort of file, there's a few different pieces that we have to make sure are ready to accept it. The first one is, we have to move to our order.html. In our form, we have to specify that it's going to be able to take this type of information. In our form here, we'll just do it right before the action, we'll say enctype =, and then we're going to have this be equal to, and look we already have the suggestion here, we want multipart/form-data, meaning that the user should be able to select some sort of file and add it to the following form. We've got to make that change, we'll go ahead and hit Command + S, save that. Then, if we're going to be accepting images into our project, we're going to have to move over…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Adding models5m 59s
-
(Locked)
Model forms4m 1s
-
Working with widgets5m 37s
-
(Locked)
Advanced widgets4m 23s
-
(Locked)
Forms and files4m 4s
-
(Locked)
Formsets: Multiple forms on a page5m 18s
-
(Locked)
Formset views6m 34s
-
(Locked)
Controlling the number of formsets5m 40s
-
(Locked)
Editing objects4m 40s
-
(Locked)
Input confirmation4m 7s
-
(Locked)
-
-