Janggo Korean file download problem

Asked 2 years ago, Updated 2 years ago, 51 views

post = get_object_or_404(Post_Notice, id = id)
filename = post.file_attached.name.split('/')[-1] 
response = HttpResponse(post.file_attached, content_type = 'application/force-download')    
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)   
return response

Create a view function in django as above

If you return HttpResponse,

It's okay when the file name is English

If it contains Korean or special characters

The download file name is invalid or missing at all.

What should I do?<

django python

2022-09-22 19:31

1 Answers

If you have a problem with Korean or special characters in the filename, convert it using urlencode and use it.

Note: urlib.parse


2022-09-22 19:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.