Learn to upload images (which can be used for product photos) through the ImageField and file uploads through the FileField in a serializer.
- [Narrator] Through the REST API we should be able … to update existing product images … or upload new product photos. … So, let's add the photo field. … Go to the product serializer. … We add the photo field. … And we add it to the list of fields... … in meta. … Recall that serializer fields can be set as read-only. … They can also be set as write-only. … This means that when we write … to the field the data does not get saved to the model. … Now let's do something more interesting. … We're going to allow the uploading … of a warranty file for a product. … We use the file field for this, … but since the product model does not have … a warranty file field in the model itself, … we're going to be adding the write-only configuration option. … We're going to override... … the update method, … so that we can make use of the warranty field. … If a warranty file is supplied, … we're going to add it to the description of the product. … We read-in all the lines from the file, … and then we return the instance. …
- Creating a serializer
- Working with API views
- Filtering back ends
- Enabling pagination
- Executing CRUD operations
- Managing serializer fields
- Testing API views
Skill Level Intermediate
Deploying Django Apps: Make Your Site Go Livewith Nick Walter2h 43m Intermediate
Demo project overview1m 19s
1. Serializing, Listing, Filtering, and Paginating Models
2. Create, Retrieve, Update, and Delete (CRUD) Operations for Models
3. Managing Serializer Fields, Relations, and Validation
4. Testing API Views
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.