简体   繁体   English

使用谷歌应用引擎在 django 的模板上显示图像

[英]show images on the templates of django using google app engine

i am using google app engine with django to make a small application that it has these features我正在使用带有 django 的谷歌应用程序引擎来制作一个具有这些功能的小型应用程序

  1. upload images,上传图片,
  2. show images,显示图像,
  3. minipulate images (rotate)缩小图像(旋转)

well after finishing part 1, now i am somewhere stuck in part 2 where i need to show images.在完成第 1 部分之后,现在我被困在第 2 部分的某个地方,我需要显示图像。
i did everything i retrieved the image keys, but the images are not showing.我做了所有我检索图像密钥的事情,但图像没有显示。
only the titles of the images i saved in the datastore.只有我保存在数据存储中的图像的标题。

here is my code:这是我的代码:

    <ul>
        {% for image in image.all %}
            <li>{{ image.title }}   </li>
            <li> <img  src="/pictures/models.{{image.key}}"/>   </li>
        {% endfor %}
    </ul>

Assuming假设

  • You uploaded the images to the blobstore您已将图像上传到 blobstore
  • image.key is the blobstore key image.key 是 blobstore 键
  • You have a handler named BlobstoreImageHandler for /pictures/models\.(.*)/您有一个名为 BlobstoreImageHandler 的处理程序,用于/pictures/models\.(.*)/

Then you'd do something like然后你会做类似的事情

class BlobstoreImageHandler(blobstore.handler.BlobstoreDownloadHandler):
  def get(self, resource):
    resourse = str(urllib.unquote(resource))
    blob_info = blobstore.BlobInfo.get(resource)
    self.send_blob(blob_info)

which is straight out of http://code.google.com/appengine/docs/python/blobstore/overview.html#Serving_a_Blob直接来自http://code.google.com/appengine/docs/python/blobstore/overview.html#Serving_a_Blob

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Google App Engine在金字塔中使用Mako模板 - Using Mako Templates in Pyramid with Google App Engine 在 Django 模板中显示图像 - show images in Django templates 使用Django模板为Google App Engine访问实体列表中具有特定ReferenceProperty值的实体 - Using Django templates for Google App Engine to access an entity with specific ReferenceProperty value from a list of entities 将WTForms与Google App Engine上的webapp和Django模板一起使用 - Use WTForms with webapp and Django templates on Google App Engine 在Google App Engine中将docx文件呈现为Django模板 - Rendering docx files as django templates in Google App Engine 在Google App Engine中对Django模板进行单元测试会引发TemplateDoesNotExist(name) - Unit testing Django templates in Google App Engine raises TemplateDoesNotExist(name) 使用Google App Engine和python上传图像 - upload images using google app engine and python 使用谷歌应用引擎和python合并2个图像? - Merge 2 images using google app engine and python? 使用Google App Engine和Python上传图像 - Uploading Images using google app engine with Python 在Google App Engine上使用XHTML2PDF时,为什么我的图像不显示? - Why do my images not show up when using XHTML2PDF on Google App Engine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM