Activity 8.01 – image and PDF upload of books
In this activity, you will start by cleaning up (deleting) the example views, templates, forms, models, and URL maps that we were using throughout the exercises in this chapter. You’ll then need to generate and apply a migration to delete ExampleModel
from the database.
You can then start adding the Bookr enhancements, first by adding ImageField
and FileField
to the Book
model to store the Book cover
and sample
. Then you will create a migration and apply it to add these fields to the database. You can then build a form that will display just these new fields. You’ll add a view that uses this form to save the model instance with the uploaded files after first resizing the image to a thumbnail size. You will be able to reuse the instance-form.html
template from Chapter 7, Advanced Form Validation and Model Forms, with a minor change to allow file uploads.
These steps will help you complete the activity:
-
...