def download_article(request, article_index): article = Article.objects.get(id=article_index) ArticleDownload.add_download(article) file_manager = ArticleFilesManager(article_index) filepath = file_manager.get_pdf_file_path() wrapper = FileWrapper(file(filepath)) response = HttpResponse(wrapper, content_type='text/plain') response['Content-Disposition'] = 'attachment; filename="%s"' % (str(article.id) + '.pdf') response['Content-Length'] = os.path.getsize(filepath) return response