Hello everyone, I am trying to run this code inside view.py, to make PDF file able to be downloaded :
> import os > BASE_DIR = os.path.dirname(os.path.dirname(__file__)) def > download(request, file_name = 'article1'): > file = open(os.path.join(BASE_DIR, > 'media').replace('\\','/').format(file_name), 'rb') > response = HttpResponse(file, content_type='application/pdf') > response['Content-Disposition'] = "attachment; > filename={}".format(file_name) > return response > > The problem with line 4. I will get *PermissionError *on windows PermissionError at /download/ > [Errno 13] Permission denied: 'C:/Users/Oana/Desktop/tutela-net/media' > > and *IsADirectoryError* on linux. Even though, if I will use 'wb' instead of 'rb' or any other options. or the absolute path, I will get the same error. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/25e64be7-ed56-43bb-862e-76eeb3ecdfba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.