如何将图像URL放在openpyxl中 - Django

时间:2016-08-17 20:23:13

标签: python django openpyxl

我已经阅读了Load an image的文档,但是当我尝试这个时,我有一个FileNotFoundError。在我的Django webapp中,所有图像都可以在DEBUG上运行,也可以在Deploy上运行,我已经配置了Apache来为它们服务,所以没有问题。

这些是我尝试过的网址:

img = Image('../../archivos/blusapolo.jpg')
img = Image('blusapolo.jpg')
img = Image(settings.MEDIA_URL+'blusapolo.jpg')
img = Image('http://127.0.0.1:8000/archivos/blusapolo.jpg')

最后一次只是一次尝试,我知道我需要一个"亲戚"路径,或者它被称为。

我的问题是,使用DJango可以使用openpyxl将图像保存到xlsx文件吗?怎么样?

这是我的追溯:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/excel/?numero=57

Django Version: 1.8
Python Version: 3.4.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'myapp',
 'django_tables2')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)
File "/home/developer/mysystem/myapp/viewCotizacion.py" in get
  135.         img = Image('/archivos/blusapolo.jpg')#,size=(75,100)
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/openpyxl/drawing/image.py" in __init__
  49.         self.image = _import_image(img)
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/openpyxl/drawing/image.py" in _import_image
  36.         img = PILImage.open(img)
File "/home/developer/mysystem/systemvenv/lib/python3.4/site-packages/PIL/Image.py" in open
  2280.         fp = builtins.open(filename, "rb")

Exception Type: FileNotFoundError at /cotizaciones/
Exception Value: [Errno 2] No such file or directory: '/archivos/blusapolo.jpg'

0 个答案:

没有答案