I am able to generate the bar code and save the image file in the root folder using this library python-barcode. Now I am trying to generate the bar code image and download via browser as HttpResponse
Here are my tryouts,
import barcode
from django.http import HttpResponse
def download_bar_code(request):
ean = barcode.get('upc', '123456789102', writer=ImageWriter())
ean.save('filename')
image = ean.render() # Returns PIL image class
# <PIL.Image.Image image mode=RGB size=523x280 at 0x7FAE2B471320>
return HttpResponse(image, content_type="image/png")
Here the image file is saving in the root folder, but not downloading via a browser. I am not able to find the solution for this, I request you to please suggest me some solution to solve this, it would be very grateful for me. Thanks in advance.