Skip to content

Commit

Permalink
DjangoCSV - v0.6.3
Browse files Browse the repository at this point in the history
- Set file downloading way to previous
  • Loading branch information
sh-mykola committed Jan 4, 2021
1 parent f92b32d commit 0e1b624
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
login as login_user,
logout as logout_user
)
from django.http import JsonResponse, HttpResponse
from django.http import FileResponse, JsonResponse
from django.shortcuts import render, redirect

from pathlib import Path

from main.forms import SchemasNewForm, SchemasNewCategories, SchemasColumnFormset, DatasetForm
from main.models import Schemas, DataSets
from .tasks import generate_file_async
Expand Down Expand Up @@ -172,10 +170,8 @@ def download(request, id_schema, id_dataset):
# Updating request with file
else:
filename = dataset_download.file.path
with open(filename, 'rb') as fh:
request = HttpResponse(fh.read(), content_type="text/csv")
request['Content-Disposition'] = f'inline; filename={Path(filename).name}'
return request
request = FileResponse(open(filename, 'rb'), "text/csv")
return request
else:
messages.add_message(request, messages.ERROR, "It is seems, that this dataset does not exist :(")

Expand Down

0 comments on commit 0e1b624

Please sign in to comment.