Tell me how in Django to allow an authorized user to download certain files (intended for him)? To this link failed to download the file in another browser or computer. And another authorized user could only download their files, and not strangers.

Found two solutions: django-downloadview and django-sendfile . You can also use HttpResponse .

As I understand it is possible to use with small files. Example:

 def download(request): my_data = 'some xls file' response = HttpResponse(my_data, content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=file.xls' return response 

    1 answer 1

    In django-sendfile, you can use different backends that are responsible for transferring the file itself.

    The sendfile.backends.development and sendfile.backends.simple backends return a file using Django, and all the file transfer logic goes through python and Django.

    Other backends use various mechanisms that transmit to the web server (apache, nginx, lighthttpd) an instruction with information about which file to transfer. In this case, Django creates a special response with a header that contains the path to the file and that the web server understands, X-Sendfile, Location or X-Accept-Redirect. But this method requires the web server to support any of the above headers. In this case, the entire burden of transferring the file falls on the shoulders of the web server, not Django, and you can use this method in production.