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
If you have a problem with Korean or special characters in the filename, convert it using urlencode and use it.
Note: urlib.parse
© 2024 OneMinuteCode. All rights reserved.