How it works...

The download_quote_picture() view streams the picture from a specific inspirational quote. The Content-Disposition header that is set to attachment makes the file downloadable instead of being immediately shown in the browser. The filename for the file is also set in this header, and will be something similar to walt-disney---if-you-can-dream-it-you-can-do-it.png. As a bonus, if the quote has no picture, a 404 page is shown with a very simple message, as follows:

The @login_required decorator will redirect the visitor to the login page if he or she tries to access the downloadable file without being logged in. As we want to have a nice Bootstrap-style login form, we are using customized Bootstrap markup in our login.html override template, which is automatically rendered through LoginView for the login form.

Depending on the custom CSS applied, the login form might look similar to the following:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.196.103