Skip to content
Advertisement

Django : transform a function download view into a class view

I am trying to rewrite a function view that download files into a classview. However I don’t see how to do it properly with the right methods, since I have an argument from the url. Then I do not which on of the class view I should be using.

I did an attemps that is worrking, but I do not see why it works with a get method. Anyone can explain me ?

Here is my function view that is working:

Function views.py:

JavaScript

urls.py:

JavaScript

template file or html:

JavaScript

Advertisement

Answer

The path for download class based view:

JavaScript

The view from the View:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement